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/08/23 21:25:31 UTC

[GitHub] [arrow-datafusion] andygrove opened a new pull request, #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

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

   # 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/3240
   
    # 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.  
   -->
   
   `create_physical_expression` accepts an Arrow schema and a DataFusion schema. They should have the same number of fields but there was no check.
   
   # 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.
   -->
   
   - Add an assertion that both schemas have the same length
   - Fix regressions caused by this change
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   Not  sure
   
   <!--
   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] codecov-commenter commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1224952580

   # [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/3242?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > :exclamation: No coverage uploaded for pull request base (`master@9ecf277`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#section-missing-base-commit).
   > The diff coverage is `93.33%`.
   
   ```diff
   @@            Coverage Diff            @@
   ##             master    #3242   +/-   ##
   =========================================
     Coverage          ?   85.83%           
   =========================================
     Files             ?      293           
     Lines             ?    53179           
     Branches          ?        0           
   =========================================
     Hits              ?    45646           
     Misses            ?     7533           
     Partials          ?        0           
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/3242?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [datafusion/core/src/datasource/view.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/3242/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9jb3JlL3NyYy9kYXRhc291cmNlL3ZpZXcucnM=) | `86.57% <87.50%> (ø)` | |
   | [datafusion/optimizer/src/expr\_simplifier.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/3242/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL2V4cHJfc2ltcGxpZmllci5ycw==) | `100.00% <100.00%> (ø)` | |
   | [datafusion/optimizer/src/simplify\_expressions.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/3242/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9vcHRpbWl6ZXIvc3JjL3NpbXBsaWZ5X2V4cHJlc3Npb25zLnJz) | `84.05% <100.00%> (ø)` | |
   | [datafusion/physical-expr/src/planner.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/3242/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9wbGFubmVyLnJz) | `95.31% <100.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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] liukun4515 commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1225784871

   I will review it tomorrow, it's too later for me today. @andygrove 


-- 
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] matthewmturner commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1228926489

   @andygrove sorry i didnt get to this sooner, looks good.


-- 
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] ursabot commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1227028674

   Benchmark runs are scheduled for baseline = 82da46d7725d6410074de7dd53b37c5f7df6a4c2 and contender = 92110ddba004ca585649d1ba97dcb67f20fc0779. 92110ddba004ca585649d1ba97dcb67f20fc0779 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/c8ac61d2baaa4ca2b50db9e80e1f493f...3b8ccb4113754353b4fc3e95f98b5a6b/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/75f9fc263abb44b19592e46b465764b7...b8976f26c93f4044975c26fa090c5513/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/afa3064380c941f4a0968d8f59bb7e72...d2f69a1d608647fc8748b12ae0b28688/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/a9614b38940c4373bf45330121da56d7...1cd907d12dc0454094d79a99b1bada99/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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 pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1225748871

   > These could easily be optimized out if we could run the optimizer here, but we can't. This also means we lose projection push-down when selecting from a view. This does at least fix the correctness issue, even if this is not efficient so it might be best to file a specific issue for this. I'll take another look at this tomorrow.
   
   I was wrong about this. We are optimizing. I will add a check to avoid adding a redundant projection.


-- 
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 #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

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


-- 
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 pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1224909782

   @matthewmturner @DaltonModlin @kmitchener Since this affects views, could you please review if you have time?


-- 
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] kmitchener commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
kmitchener commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1224952773

   > @matthewmturner @DaltonModlin @kmitchener Since this affects views, could you please review if you have time?
   
   LGTM. If you want to reproduce, this triggered the error prior to the fix:
   ```sql
   create view v as select 1 as a, 2 as b, 3 as c;
   select * from (select b from v); -- returned column a prior to fix
   ```


-- 
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] kmitchener commented on pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
kmitchener commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1224969592

   Given the above sql, it results in this plan. Isn't this 1 too many projections?
   
   ```
   create view v as select 1 as a, 2 as b, 3 as c;
   explain analyze select * from (select b from v);
   +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | plan_type         | plan                                                                                                                                                                         |
   +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | Plan with Metrics | CoalescePartitionsExec, metrics=[output_rows=1, elapsed_compute=72.1µs, spill_count=0, spilled_bytes=0, mem_used=0]                                                          |
   |                   |   ProjectionExec: expr=[b@0 as b], metrics=[output_rows=1, elapsed_compute=3.311µs, spill_count=0, spilled_bytes=0, mem_used=0]                                              |
   |                   |     ProjectionExec: expr=[b@0 as b], metrics=[output_rows=1, elapsed_compute=5.511µs, spill_count=0, spilled_bytes=0, mem_used=0]                                            |
   |                   |       ProjectionExec: expr=[2 as b], metrics=[output_rows=1, elapsed_compute=53.011µs, spill_count=0, spilled_bytes=0, mem_used=0]                                           |
   |                   |         RepartitionExec: partitioning=RoundRobinBatch(12), metrics=[repart_time{inputPartition=0}=1ns, fetch_time{inputPartition=0}=27µs, send_time{inputPartition=0}=7.6µs] |
   |                   |           EmptyExec: produce_one_row=true, metrics=[]                                                                                                                        |
   |                   |                                                                                                                                                                              |
   +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   
   ```


-- 
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 pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1225004505

   > Given the above sql, it results in this plan. Isn't this 1 too many projections?
   > 
   > ```
   > create view v as select 1 as a, 2 as b, 3 as c;
   > explain analyze select * from (select b from v);
   > +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > | plan_type         | plan                                                                                                                                                                         |
   > +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > | Plan with Metrics | CoalescePartitionsExec, metrics=[output_rows=1, elapsed_compute=72.1µs, spill_count=0, spilled_bytes=0, mem_used=0]                                                          |
   > |                   |   ProjectionExec: expr=[b@0 as b], metrics=[output_rows=1, elapsed_compute=3.311µs, spill_count=0, spilled_bytes=0, mem_used=0]                                              |
   > |                   |     ProjectionExec: expr=[b@0 as b], metrics=[output_rows=1, elapsed_compute=5.511µs, spill_count=0, spilled_bytes=0, mem_used=0]                                            |
   > |                   |       ProjectionExec: expr=[2 as b], metrics=[output_rows=1, elapsed_compute=53.011µs, spill_count=0, spilled_bytes=0, mem_used=0]                                           |
   > |                   |         RepartitionExec: partitioning=RoundRobinBatch(12), metrics=[repart_time{inputPartition=0}=1ns, fetch_time{inputPartition=0}=27µs, send_time{inputPartition=0}=7.6µs] |
   > |                   |           EmptyExec: produce_one_row=true, metrics=[]                                                                                                                        |
   > |                   |                                                                                                                                                                              |
   > +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > ```
   
   These could easily be optimized out if we could run the optimizer here, but we can't. This also means we lose projection push-down when selecting from a view. This does at least fix the correctness issue, even if this is not efficient so it might be best to file a specific issue for this. I'll take another look at this tomorrow.


-- 
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 pull request #3242: Add assertion for invariant in `create_physical_expression` and fix ViewTable projection

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #3242:
URL: https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1225806077

   I filed https://github.com/apache/arrow-datafusion/issues/3248 for removing the redundant projection. The physical plan being returned from `ViewTable::scan` does not have it, so I think this is a bug that is unrelated to this PR.
   
   ViewScan::scan returns this:
   
   ```
   ProjectionExec: expr=[b@0 as b]
     ProjectionExec: expr=[2 as b]
       EmptyExec: produce_one_row=true
   ```
   
   `EXPLAIN ANALYZE` shows this:
   
   ```
   +---------------+---------------------------------------+
   | plan_type     | plan                                  |
   +---------------+---------------------------------------+
   | logical_plan  | Projection: #v.b                      |
   |               |   TableScan: v projection=[b]         |
   | physical_plan | ProjectionExec: expr=[b@0 as b]       |
   |               |   ProjectionExec: expr=[b@0 as b]     |
   |               |     ProjectionExec: expr=[2 as b]     |
   |               |       EmptyExec: produce_one_row=true |
   |               |                                       |
   +---------------+---------------------------------------+
   ```


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