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/11/16 06:04:36 UTC

[GitHub] [arrow-datafusion] jackwener opened a new pull request, #4233: add a check to confirm optimizer can keep plan schema immutable.

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

   # 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.  
   -->
   
   # 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.
   -->
   
   # 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] mingmwang commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   @jackwener 
   Is it possible that the check can not always pass in case that some of the optimization rules might change the nullability of the Schema ? 
   For example a Column Expression was replaced by a Literal Constant due to Constant propagation ?
   
   `EXPLAIN EXTENDED select max(t1.id) from (select 123 as id ) as t1 where t1.id = 123;`



##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   @jackwener 
   Is it possible that the check can not always pass in case that some of the optimization rules might change the nullability of the Schema ? 
   For example a Column Expression was replaced by a Literal Constant due to Constant propagation ?
   
   `select max(t1.id) from (select 123 as id ) as t1 where t1.id = 123;`



-- 
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 #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


-- 
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] mingmwang commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   @jackwener 
   Is it possible that the check can not always pass in case that some of the optimization rules might change the nullability of the Schema ? 
   For example and Column Expression was replaced by a Literal Constant due to Constant propagation ?



-- 
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] mingmwang commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   @jackwener 
   Is it possible that the check can not always pass in case that some of the optimization rules might change the nullability of the Schema ? 
   For example a Column Expression was replaced by a Literal Constant due to Constant propagation ?
   
   `Select MAX(A.id) from Table A where A.id = 12345;`



-- 
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] jackwener commented on pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   Thanks @andygrove review. 
   polish error message to  add the expected and actual schema, and add a UT.


-- 
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] mingmwang commented on pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   > > I think we also need to do the same check for physical optimizer.
   > 
   > Sounds like a good idea. Do you want to file an issue for that?
   
   Yes, track this via https://github.com/apache/arrow-datafusion/issues/4299
   


-- 
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] jackwener commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   Indeed, we may need to relax restrictions on some conditions, such as `nullable`.
   



-- 
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 #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   Thanks @jackwener. This is a good improvement. Could you fill out the PR description? It helps with the reviews.


-- 
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] mingmwang commented on pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   I think we also need to do the same check for physical optimizer.


-- 
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] jackwener commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   Indeed, we may need to relax restrictions on some conditions, such as `nullable`.
   In this way we can get more room for optimization.
   But in most cases, we don't need to do this, we can wait until we need to do this



-- 
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] mingmwang commented on pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   This is really 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] ursabot commented on pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   Benchmark runs are scheduled for baseline = 6f62870e6e640c4a3f486fbe9bdf49b30c0b5c34 and contender = 5ed40e0d2b849e7591040e42c33b20188fc8a052. 5ed40e0d2b849e7591040e42c33b20188fc8a052 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/aef3e3bcad704d4491dcb0502f76bb73...cb79edf952a44bbc919553a994cba502/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/b2fb7a2ed0e9441f81d7e8b64fafd2f6...4a32682ec5d14926aa7135b6d48d789a/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/09472988a655489dbdde73359e1d56b6...a9ff745d4dab42648b8ca7d4a6c25991/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/61f2ade791f947ee921f47da7435ee1a...878cd9f22eff428a8ae1bf5245e1b263/)
   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 #4233: add a checker to confirm optimizer can keep plan schema immutable.

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

   > I think we also need to do the same check for physical optimizer.
   
   Sounds like a good idea. Do you want to file an issue for that?


-- 
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 #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -223,6 +223,12 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   Could we include the expected and actual schema in the error message? This will make debugging much easier.



##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -223,6 +223,12 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   Also, could you add a unit test?



-- 
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] mingmwang commented on a diff in pull request #4233: add a checker to confirm optimizer can keep plan schema immutable.

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -225,6 +225,14 @@ impl Optimizer {
                 let result = rule.try_optimize(&new_plan, optimizer_config);
                 match result {
                     Ok(Some(plan)) => {
+                        if plan.schema() != new_plan.schema() {
+                            return Err(DataFusionError::Internal(format!(

Review Comment:
   @jackwener 
   Is it possible that the check can not always pass in case that some of the optimization rules might change the nullability of the Schema ? 
   For example a Column Expression was replaced by a Literal Constant due to Constant propagation ?



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