You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/03 15:26:56 UTC

[GitHub] [arrow-datafusion] andygrove opened a new pull request, #2690: Show column names instead of indices in TableProvider projection plan output

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

   # 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 https://github.com/apache/arrow-datafusion/issues/2689
   
    # 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 am comparing query plans between Spark and DataFusion
   
   Spark shows:
   
   ```
   FileScan parquet [ss_sold_time_sk#215,ss_hdemo_sk#219,ss_store_sk#221] ...
   ```
   
   DataFusion shows:
   
   ```
   TableScan: store_sales projection=Some([1, 5, 7])
   ```
   
   I think we should show column names rather than numeric indices so that users don't have to memorize the schemas of the tables in order to comprehend the query plan.
   
   # 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.
   -->
   
   Show names instead of indices.
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   Yes, plans are easier to understand.
   
   <!--
   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] andygrove merged pull request #2690: Show column names instead of indices in query plans

Posted by GitBox <gi...@apache.org>.
andygrove merged PR #2690:
URL: https://github.com/apache/arrow-datafusion/pull/2690


-- 
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] Dandandan commented on a diff in pull request #2690: Show column names instead of indices in query plans

Posted by GitBox <gi...@apache.org>.
Dandandan commented on code in PR #2690:
URL: https://github.com/apache/arrow-datafusion/pull/2690#discussion_r889492584


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -656,10 +656,22 @@ impl LogicalPlan {
                         ref limit,
                         ..
                     }) => {
+                        let projected_fields = match projection {
+                            Some(indices) => {
+                                let schema = source.schema();
+                                let names: Vec<&str> = indices
+                                    .iter()
+                                    .map(|i| schema.field(*i).name().as_str())
+                                    .collect();
+                                format!("Some([{}])", names.join(", "))

Review Comment:
   What about only showing the projection when there is one and ommiting it when there are none.
   This could remove the None/Some too:
   
   `TableScan a projection=[col1,col2]`
   vs
   `TableScan a` 



-- 
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] andygrove commented on a diff in pull request #2690: Show column names instead of indices in query plans

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2690:
URL: https://github.com/apache/arrow-datafusion/pull/2690#discussion_r889615100


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -656,10 +656,22 @@ impl LogicalPlan {
                         ref limit,
                         ..
                     }) => {
+                        let projected_fields = match projection {
+                            Some(indices) => {
+                                let schema = source.schema();
+                                let names: Vec<&str> = indices
+                                    .iter()
+                                    .map(|i| schema.field(*i).name().as_str())
+                                    .collect();
+                                format!("Some([{}])", names.join(", "))

Review Comment:
   I started out doing that and it broke many tests that were expecting `None` so I decided to reduce the size of the change. I agree that it would be a nice improvement though. I'm happy to work on that as a follow-on PR.



-- 
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] Dandandan commented on a diff in pull request #2690: Show column names instead of indices in query plans

Posted by GitBox <gi...@apache.org>.
Dandandan commented on code in PR #2690:
URL: https://github.com/apache/arrow-datafusion/pull/2690#discussion_r889492584


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -656,10 +656,22 @@ impl LogicalPlan {
                         ref limit,
                         ..
                     }) => {
+                        let projected_fields = match projection {
+                            Some(indices) => {
+                                let schema = source.schema();
+                                let names: Vec<&str> = indices
+                                    .iter()
+                                    .map(|i| schema.field(*i).name().as_str())
+                                    .collect();
+                                format!("Some([{}])", names.join(", "))

Review Comment:
   What about only showing the projection when there is one and ommiting it when there are none.
   This could remove the None/Some too:
   
   `TableScan a projection=[col1,col2] filter`
   vs
   `TableScan a` 



-- 
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] andygrove commented on a diff in pull request #2690: Show column names instead of indices in query plans

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2690:
URL: https://github.com/apache/arrow-datafusion/pull/2690#discussion_r889615218


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -656,10 +656,22 @@ impl LogicalPlan {
                         ref limit,
                         ..
                     }) => {
+                        let projected_fields = match projection {
+                            Some(indices) => {
+                                let schema = source.schema();
+                                let names: Vec<&str> = indices
+                                    .iter()
+                                    .map(|i| schema.field(*i).name().as_str())
+                                    .collect();
+                                format!("Some([{}])", names.join(", "))

Review Comment:
   Filed https://github.com/apache/arrow-datafusion/issues/2697



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