comphead commented on code in PR #6539:
URL: https://github.com/apache/arrow-datafusion/pull/6539#discussion_r1218282195


##########
datafusion/sql/src/statement.rs:
##########
@@ -569,11 +569,47 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         }))
     }
 
-    fn copy_to_plan(&self, _statement: CopyToStatement) -> Result<LogicalPlan> 
{
+    fn copy_to_plan(&self, statement: CopyToStatement) -> Result<LogicalPlan> {
         // TODO: implement as part of 
https://github.com/apache/arrow-datafusion/issues/5654
-        Err(DataFusionError::NotImplemented(
-            "`COPY .. TO ..` statement is not yet supported".to_string(),
-        ))
+        //Err(DataFusionError::NotImplemented(
+        //"`COPY .. TO ..` statement is not yet supported".to_string(),
+        //))
+        let CopyToStatement { source, target, options } = statement;
+        let input = match source {
+            CopyToSource::Relation(table_name) => {
+                // TODO create at table scan here
+
+                return Err(DataFusionError::Plan(
+                "COPY FROM TABLE not yet supported."
+                        .to_owned(),
+                ));
+            }
+            CopyToSource::Query(query) => {
+                self.query_to_plan(query, &mut PlannerContext::new())?
+            },
+        };
+
+        // figure out what to do with the target?
+        // should we treat it like a table name???

Review Comment:
   PG treats it as files https://www.postgresql.org/docs/current/sql-copy.html
   
   `filename`
   The path name of the input or output file. An input file name can be an 
absolute or relative path, but an output file name must be an absolute path. 
Windows users might need to use an E'' string and double any backslashes used 
in the path name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to