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

[GitHub] [arrow-datafusion] waynexia opened a new pull request, #5716: fix: parse table name into TableReference on converting substrait read

waynexia opened a new pull request, #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716

   # 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.
   -->
   
   Closes #.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   I found this when [replacing](https://github.com/GreptimeTeam/greptimedb/issues/1013) our substrait implementation with DataFusion's. The `TableScan` plan was created in the format of `catalog.schema.table` will be treated as a whole name string, and leads to a table not found error.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Parse table name to `TableReference` and put catalog, schema and table into three parts corresponding to the consumer's logic.
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#discussion_r1148394450


##########
datafusion/common/src/table_reference.rs:
##########
@@ -408,4 +427,26 @@ mod tests {
         let actual = TableReference::from("TABLE()");
         assert_eq!(expected, actual);
     }
+
+    #[test]
+    fn test_table_reference_to_vector() {
+        let table_reference = TableReference::parse_str("table");
+        assert_eq!(vec!["table".to_string()], table_reference.to_vec());
+
+        let table_reference = TableReference::parse_str("schema.table");
+        assert_eq!(
+            vec!["schema".to_string(), "table".to_string()],

Review Comment:
   nice



-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#issuecomment-1483314423

   cc @Jefffrey  


-- 
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


[GitHub] [arrow-datafusion] Jefffrey commented on a diff in pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#discussion_r1148309928


##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -109,6 +110,17 @@ pub fn to_substrait_rel(
             });
 
             if let Some(struct_items) = projection {
+                let names = match &scan.table_name {
+                    TableReference::Bare { table } => vec![table.to_string()],
+                    TableReference::Partial { schema, table } => {
+                        vec![schema.to_string(), table.to_string()]
+                    }
+                    TableReference::Full {
+                        catalog,
+                        schema,
+                        table,
+                    } => vec![catalog.to_string(), schema.to_string(), table.to_string()],
+                };

Review Comment:
   could move this logic into a function on TableReference itself, since would future proof in case ever want to support nested namespaces in future



-- 
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


[GitHub] [arrow-datafusion] waynexia commented on pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#issuecomment-1483846198

   > I wonder if there is some way to add a test for this behavior?
   
   Thanks for reviewing, I add two cases `qualified_schema_table_reference` and `qualified_catalog_schema_table_reference` to cover.


-- 
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


[GitHub] [arrow-datafusion] alamb merged pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716


-- 
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


[GitHub] [arrow-datafusion] waynexia commented on pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#issuecomment-1482512422

   cc @andygrove @nseekhao 


-- 
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


[GitHub] [arrow-datafusion] waynexia commented on a diff in pull request #5716: fix: parse table name into TableReference on converting substrait read

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #5716:
URL: https://github.com/apache/arrow-datafusion/pull/5716#discussion_r1148387938


##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -109,6 +110,17 @@ pub fn to_substrait_rel(
             });
 
             if let Some(struct_items) = projection {
+                let names = match &scan.table_name {
+                    TableReference::Bare { table } => vec![table.to_string()],
+                    TableReference::Partial { schema, table } => {
+                        vec![schema.to_string(), table.to_string()]
+                    }
+                    TableReference::Full {
+                        catalog,
+                        schema,
+                        table,
+                    } => vec![catalog.to_string(), schema.to_string(), table.to_string()],
+                };

Review Comment:
   :+1: I move it to `TableReference::to_vec()`



-- 
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