You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ozankabak (via GitHub)" <gi...@apache.org> on 2023/06/05 03:36:29 UTC

[GitHub] [arrow-datafusion] ozankabak commented on a diff in pull request #6526: Add support for appending data to external tables - CSV

ozankabak commented on code in PR #6526:
URL: https://github.com/apache/arrow-datafusion/pull/6526#discussion_r1217419825


##########
datafusion/core/src/datasource/listing/table.rs:
##########
@@ -759,6 +759,62 @@ impl TableProvider for ListingTable {
     fn get_table_definition(&self) -> Option<&str> {
         self.definition.as_deref()
     }
+
+    async fn insert_into(
+        &self,
+        state: &SessionState,
+        input: Arc<dyn ExecutionPlan>,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        // Check that the schema of the plan matches the schema of this table.
+        if !input.schema().eq(&self.schema()) {
+            return Err(DataFusionError::Plan(
+                // Return an error if schema of the input query does not match with the table schema.
+                "Inserting query must have the same schema with the table.".to_string(),
+            ));
+        }
+
+        if self.table_paths().len() > 1 {
+            return Err(DataFusionError::Plan(
+                "Datafusion currently supports tables from single file.".to_owned(),

Review Comment:
   Done 👍 



##########
datafusion/core/src/datasource/listing/table.rs:
##########
@@ -759,6 +759,62 @@ impl TableProvider for ListingTable {
     fn get_table_definition(&self) -> Option<&str> {
         self.definition.as_deref()
     }
+
+    async fn insert_into(
+        &self,
+        state: &SessionState,
+        input: Arc<dyn ExecutionPlan>,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        // Check that the schema of the plan matches the schema of this table.
+        if !input.schema().eq(&self.schema()) {
+            return Err(DataFusionError::Plan(
+                // Return an error if schema of the input query does not match with the table schema.
+                "Inserting query must have the same schema with the table.".to_string(),
+            ));
+        }
+
+        if self.table_paths().len() > 1 {
+            return Err(DataFusionError::Plan(
+                "Datafusion currently supports tables from single file.".to_owned(),
+            ));
+        }
+
+        let table_path = &self.table_paths()[0];
+        // Get the object store for the table path.
+        let store = state.runtime_env().object_store(table_path)?;
+
+        let file_list_future = pruned_partition_list(

Review Comment:
   Agreed, done



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org