@@ -24,7 +24,7 @@ use arrow::datatypes::{DataType, Field, Schema};
2424use datafusion_common:: file_options:: file_type:: FileType ;
2525use datafusion_common:: { DFSchemaRef , TableReference } ;
2626
27- use crate :: LogicalPlan ;
27+ use crate :: { LogicalPlan , TableSource } ;
2828
2929/// Operator that copies the contents of a database to file(s)
3030#[ derive( Clone ) ]
@@ -73,12 +73,12 @@ impl Hash for CopyTo {
7373
7474/// The operator that modifies the content of a database (adapted from
7575/// substrait WriteRel)
76- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
76+ #[ derive( Clone ) ]
7777pub struct DmlStatement {
7878 /// The table name
7979 pub table_name : TableReference ,
80- /// The schema of the table (must align with Rel input)
81- pub table_schema : DFSchemaRef ,
80+ /// The operation destination
81+ pub dst : Arc < dyn TableSource > ,
8282 /// The type of operation to perform
8383 pub op : WriteOp ,
8484 /// The relation that determines the tuples to add/remove/modify the schema must match with table_schema
@@ -87,17 +87,49 @@ pub struct DmlStatement {
8787 pub output_schema : DFSchemaRef ,
8888}
8989
90+ impl Debug for DmlStatement {
91+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
92+ f. debug_struct ( "TableScan" )
93+ . field ( "table_name" , & self . table_name )
94+ . field ( "source" , & "..." )
95+ . field ( "op" , & self . op )
96+ . field ( "input" , & self . input )
97+ . field ( "output_schema" , & self . output_schema )
98+ . finish_non_exhaustive ( )
99+ }
100+ }
101+
102+ impl PartialEq for DmlStatement {
103+ fn eq ( & self , other : & Self ) -> bool {
104+ self . table_name == other. table_name
105+ && self . op == other. op
106+ && self . input == other. input
107+ && self . output_schema == other. output_schema
108+ }
109+ }
110+
111+ impl Eq for DmlStatement { }
112+
113+ impl Hash for DmlStatement {
114+ fn hash < H : Hasher > ( & self , state : & mut H ) {
115+ self . table_name . hash ( state) ;
116+ self . op . hash ( state) ;
117+ self . input . hash ( state) ;
118+ self . output_schema . hash ( state) ;
119+ }
120+ }
121+
90122impl DmlStatement {
91123 /// Creates a new DML statement with the output schema set to a single `count` column.
92124 pub fn new (
93125 table_name : TableReference ,
94- table_schema : DFSchemaRef ,
126+ dst : Arc < dyn TableSource > ,
95127 op : WriteOp ,
96128 input : Arc < LogicalPlan > ,
97129 ) -> Self {
98130 Self {
99131 table_name,
100- table_schema ,
132+ dst ,
101133 op,
102134 input,
103135
0 commit comments