@@ -25,7 +25,7 @@ use arrow::datatypes::{DataType, Field, Schema};
2525use  datafusion_common:: file_options:: file_type:: FileType ; 
2626use  datafusion_common:: { DFSchemaRef ,  TableReference } ; 
2727
28- use  crate :: LogicalPlan ; 
28+ use  crate :: { LogicalPlan ,   TableSource } ; 
2929
3030/// Operator that copies the contents of a database to file(s) 
3131#[ derive( Clone ) ]  
@@ -91,31 +91,64 @@ impl Hash for CopyTo {
9191
9292/// The operator that modifies the content of a database (adapted from 
9393/// substrait WriteRel) 
94- #[ derive( Debug ,   Clone ,   PartialEq ,   Eq ,   Hash ) ]  
94+ #[ derive( Clone ) ]  
9595pub  struct  DmlStatement  { 
9696    /// The table name 
9797     pub  table_name :  TableReference , 
98-     /// The schema of the  table (must align with Rel input)  
99-      pub  table_schema :   DFSchemaRef , 
98+     /// this is target  table to insert into  
99+      pub  target :   Arc < dyn   TableSource > , 
100100    /// The type of operation to perform 
101101     pub  op :  WriteOp , 
102102    /// The relation that determines the tuples to add/remove/modify the schema must match with table_schema 
103103     pub  input :  Arc < LogicalPlan > , 
104104    /// The schema of the output relation 
105105     pub  output_schema :  DFSchemaRef , 
106106} 
107+ impl  Eq  for  DmlStatement  { } 
108+ impl  Hash  for  DmlStatement  { 
109+     fn  hash < H :  Hasher > ( & self ,  state :  & mut  H )  { 
110+         self . table_name . hash ( state) ; 
111+         self . target . schema ( ) . hash ( state) ; 
112+         self . op . hash ( state) ; 
113+         self . input . hash ( state) ; 
114+         self . output_schema . hash ( state) ; 
115+     } 
116+ } 
117+ 
118+ impl  PartialEq  for  DmlStatement  { 
119+     fn  eq ( & self ,  other :  & Self )  -> bool  { 
120+         self . table_name  == other. table_name 
121+             && self . target . schema ( )  == other. target . schema ( ) 
122+             && self . op  == other. op 
123+             && self . input  == other. input 
124+             && self . output_schema  == other. output_schema 
125+     } 
126+ } 
127+ 
128+ impl  Debug  for  DmlStatement  { 
129+     fn  fmt ( & self ,  f :  & mut  Formatter < ' _ > )  -> fmt:: Result  { 
130+         f. debug_struct ( "DmlStatement" ) 
131+             . field ( "table_name" ,  & self . table_name ) 
132+             . field ( "target" ,  & "..." ) 
133+             . field ( "target_schema" ,  & self . target . schema ( ) ) 
134+             . field ( "op" ,  & self . op ) 
135+             . field ( "input" ,  & self . input ) 
136+             . field ( "output_schema" ,  & self . output_schema ) 
137+             . finish ( ) 
138+     } 
139+ } 
107140
108141impl  DmlStatement  { 
109142    /// Creates a new DML statement with the output schema set to a single `count` column. 
110143     pub  fn  new ( 
111144        table_name :  TableReference , 
112-         table_schema :   DFSchemaRef , 
145+         target :   Arc < dyn   TableSource > , 
113146        op :  WriteOp , 
114147        input :  Arc < LogicalPlan > , 
115148    )  -> Self  { 
116149        Self  { 
117150            table_name, 
118-             table_schema , 
151+             target , 
119152            op, 
120153            input, 
121154
0 commit comments