You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "CTTY (via GitHub)" <gi...@apache.org> on 2025/08/13 00:44:00 UTC

[PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

CTTY opened a new pull request, #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - A part of #1540 
   - See draft: #1511 
   
   ## What changes are included in this PR?
   - Added `catalog` to `IcebergTableProvider` as optional
   - Implement `insert_into` for `IcebergTableProvider` using write node and commit node for non-partitioned tables
   <!--
   Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates.
   -->
   
   ## Are these changes tested?
   test is wip
   <!--
   Specify what test covers (unit test, integration test, etc.).
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2294954656


##########
crates/integrations/datafusion/tests/integration_datafusion_test.rs:
##########
@@ -432,3 +432,370 @@ async fn test_metadata_table() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn test_insert_into() -> Result<()> {

Review Comment:
   I will jump back on this after #1621 is completed



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2277551340


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -152,11 +174,52 @@ impl TableProvider for IcebergTableProvider {
     fn supports_filters_pushdown(
         &self,
         filters: &[&Expr],
-    ) -> std::result::Result<Vec<TableProviderFilterPushDown>, datafusion::error::DataFusionError>
-    {
+    ) -> DFResult<Vec<TableProviderFilterPushDown>> {
         // Push down all filters, as a single source of truth, the scanner will drop the filters which couldn't be push down
         Ok(vec![TableProviderFilterPushDown::Inexact; filters.len()])
     }
+
+    async fn insert_into(
+        &self,
+        _state: &dyn Session,
+        input: Arc<dyn ExecutionPlan>,
+        _insert_op: InsertOp,
+    ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        if !self
+            .table

Review Comment:
   Ideally we should refresh the table here and every other`self.table` usages in `IcebergTableProvider`, but I think we should fix that in a separate PR if needed



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600


-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2277539503


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -140,8 +152,15 @@ impl TableProvider for IcebergTableProvider {
         filters: &[Expr],
         _limit: Option<usize>,
     ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        // Refresh table if catalog is available
+        let table = if let Some(catalog) = &self.catalog {
+            catalog.load_table(self.table.identifier()).await.map_err(to_datafusion_error)?
+        } else {
+            self.table.clone()
+        };
+

Review Comment:
   This makes me wonder that if storing table directly in the `IcebergTableProvider` is correct... We could get a stale table if the provider doesn't have a catalog table. 
   
   Iceberg-java has a [`refresh()`](https://github.com/apache/iceberg/blob/7477f8bfbcf9cded7129bbf8ca7e91bcaa81c1ae/api/src/main/java/org/apache/iceberg/Table.java#L42) interface which uses `TableOperation` to refresh metadata. In iceberg-rs we don't have `TableOperation` and has to rely on catalog to refresh



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2277551340


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -152,11 +174,52 @@ impl TableProvider for IcebergTableProvider {
     fn supports_filters_pushdown(
         &self,
         filters: &[&Expr],
-    ) -> std::result::Result<Vec<TableProviderFilterPushDown>, datafusion::error::DataFusionError>
-    {
+    ) -> DFResult<Vec<TableProviderFilterPushDown>> {
         // Push down all filters, as a single source of truth, the scanner will drop the filters which couldn't be push down
         Ok(vec![TableProviderFilterPushDown::Inexact; filters.len()])
     }
+
+    async fn insert_into(
+        &self,
+        _state: &dyn Session,
+        input: Arc<dyn ExecutionPlan>,
+        _insert_op: InsertOp,
+    ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        if !self
+            .table

Review Comment:
   Ideally we should refresh the table here and every other table usages in `IcebergTableProvider`, but I think we should fix that in a separate PR if needed



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2293293046


##########
crates/integrations/datafusion/tests/integration_datafusion_test.rs:
##########
@@ -432,3 +432,370 @@ async fn test_metadata_table() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn test_insert_into() -> Result<()> {

Review Comment:
   Thanks for these tests, it would be much easier if we have sql logic tests.



##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -152,11 +174,52 @@ impl TableProvider for IcebergTableProvider {
     fn supports_filters_pushdown(
         &self,
         filters: &[&Expr],
-    ) -> std::result::Result<Vec<TableProviderFilterPushDown>, datafusion::error::DataFusionError>
-    {
+    ) -> DFResult<Vec<TableProviderFilterPushDown>> {
         // Push down all filters, as a single source of truth, the scanner will drop the filters which couldn't be push down
         Ok(vec![TableProviderFilterPushDown::Inexact; filters.len()])
     }
+
+    async fn insert_into(
+        &self,
+        _state: &dyn Session,
+        input: Arc<dyn ExecutionPlan>,
+        _insert_op: InsertOp,
+    ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        if !self
+            .table

Review Comment:
   Sounds reasonable to me.



##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -140,8 +152,15 @@ impl TableProvider for IcebergTableProvider {
         filters: &[Expr],
         _limit: Option<usize>,
     ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        // Refresh table if catalog is available
+        let table = if let Some(catalog) = &self.catalog {
+            catalog.load_table(self.table.identifier()).await.map_err(to_datafusion_error)?
+        } else {
+            self.table.clone()
+        };
+

Review Comment:
   I agree that this maybe a problem, but I don't think we should do it here? Creating another issue to track this maybe a better approach.



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2277539503


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -140,8 +152,15 @@ impl TableProvider for IcebergTableProvider {
         filters: &[Expr],
         _limit: Option<usize>,
     ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        // Refresh table if catalog is available
+        let table = if let Some(catalog) = &self.catalog {
+            catalog.load_table(self.table.identifier()).await.map_err(to_datafusion_error)?
+        } else {
+            self.table.clone()
+        };
+

Review Comment:
   This makes me wonder if storing table directly in the `IcebergTableProvider` is correct... We could get a stale table if the provider doesn't have a catalog table. 
   
   Iceberg-java has a [`refresh()`](https://github.com/apache/iceberg/blob/7477f8bfbcf9cded7129bbf8ca7e91bcaa81c1ae/api/src/main/java/org/apache/iceberg/Table.java#L42) interface which uses `TableOperation` to refresh metadata. In iceberg-rs we don't have `TableOperation` and need to rely on catalog to refresh



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2283233669


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -140,8 +152,15 @@ impl TableProvider for IcebergTableProvider {
         filters: &[Expr],
         _limit: Option<usize>,
     ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        // Refresh table if catalog is available
+        let table = if let Some(catalog) = &self.catalog {
+            catalog.load_table(self.table.identifier()).await.map_err(to_datafusion_error)?
+        } else {
+            self.table.clone()
+        };
+

Review Comment:
   Hi @phillipleblanc , thanks for pointing me to your change! Your change makes sense to me, but I was thinking of adding something like this to `impl Table` directly 
   ```
   pub async fn refresh(&mut self, catalog: &dyn Catalog) -> Result<Self>
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(datafusion): Implement `insert_into` for `IcebergTableProvider` [iceberg-rust]

Posted by "phillipleblanc (via GitHub)" <gi...@apache.org>.
phillipleblanc commented on code in PR #1600:
URL: https://github.com/apache/iceberg-rust/pull/1600#discussion_r2280656152


##########
crates/integrations/datafusion/src/table/mod.rs:
##########
@@ -140,8 +152,15 @@ impl TableProvider for IcebergTableProvider {
         filters: &[Expr],
         _limit: Option<usize>,
     ) -> DFResult<Arc<dyn ExecutionPlan>> {
+        // Refresh table if catalog is available
+        let table = if let Some(catalog) = &self.catalog {
+            catalog.load_table(self.table.identifier()).await.map_err(to_datafusion_error)?
+        } else {
+            self.table.clone()
+        };
+

Review Comment:
   I have a PR to add that functionality (including the refresh): https://github.com/apache/iceberg-rust/pull/1297



-- 
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: issues-unsubscribe@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org