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/09/21 15:01:34 UTC
[GitHub] [arrow-datafusion] thinkharderdev opened a new pull request, #3574: Fix logical plan serialization
thinkharderdev opened a new pull request, #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574
# 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 #3555
# 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.
-->
Currently round-trip logical plan serialization is broken for some aggregation queries. This happens when the `TypeCoercion` optimizer casts literal values in aggregate function expressions and then the const evaluator optimizes out the cast (replacing with a literal for the casted value). This effectively changes the expression name and causes a mismatch when rebuilding the plan after deserialization.
# 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.
-->
In `TypeCoercion` special-case the handling of aggregation function expressions to make sure we alias back to the original expression name if it has changed. This should ensure the schema is still valid and the plan can be rebuilt from its serialized representation.
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
no
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
no
--
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 #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
alamb merged PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574
--
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] thinkharderdev commented on pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1255082617
> I wonder if #3568 could be related
Yeah, if I understand that ticket correctly then it's the same underlying issue
--
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 #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1254044649
I believe this PR is going to fail its checks until is it merged to include https://github.com/apache/arrow-datafusion/pull/3576
--
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 a diff in pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#discussion_r977136191
##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -79,10 +79,29 @@ impl OptimizerRule for TypeCoercion {
const_evaluator,
};
+ let original_expr_names: Vec<Option<String>> = plan
+ .expressions()
+ .iter()
+ .map(|expr| expr.name().ok())
+ .collect();
+
let new_expr = plan
.expressions()
.into_iter()
- .map(|expr| expr.rewrite(&mut expr_rewrite))
+ .zip(original_expr_names)
+ .map(|(expr, original_name)| {
+ let expr = expr.rewrite(&mut expr_rewrite)?;
+
+ if matches!(expr, Expr::AggregateFunction { .. }) {
Review Comment:
I think this is just a workround for this issue. We should split the type coercion from the 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] alamb commented on pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1254864453
I wonder if https://github.com/apache/arrow-datafusion/issues/3568 could be related
--
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] thinkharderdev commented on pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1253841664
@alamb @andygrove This feels like a bit of hacky special casing but seemed like the least insrusive way to deal with this. If optimizers can change expression names in general though this could come up in other places w/r/t serde of aggregation plans where we rely explicitly on the expression name.
--
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 #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1254226963
Benchmark runs are scheduled for baseline = 634d912f22b18c3eb08649de0825403b91be892e and contender = 488be64889ff94244363323e0ce2f18f719ee9a4. 488be64889ff94244363323e0ce2f18f719ee9a4 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/5075222e68ec49d0a8ea6ff5d242c643...181a4a835a8b4ee784e2e21ec8c6ab37/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/465db02109c64c0a8d1e88a7fe424251...902e6cf701384bb6815e5cf87f5ab62e/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/cab20829c98d4c70b5146b9bf378d1b7...34d9d5f23209445895f4a9afd1cbf4bb/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/2fe295df8b9746d99f9d084cc4482744...9b59f74e439d46cdb0b43e31405d9bd3/)
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] alamb commented on a diff in pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#discussion_r976732342
##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -79,10 +79,29 @@ impl OptimizerRule for TypeCoercion {
const_evaluator,
};
+ let original_expr_names: Vec<Option<String>> = plan
+ .expressions()
+ .iter()
+ .map(|expr| expr.name().ok())
+ .collect();
+
let new_expr = plan
.expressions()
.into_iter()
- .map(|expr| expr.rewrite(&mut expr_rewrite))
+ .zip(original_expr_names)
+ .map(|(expr, original_name)| {
+ let expr = expr.rewrite(&mut expr_rewrite)?;
+
+ if matches!(expr, Expr::AggregateFunction { .. }) {
Review Comment:
```suggestion
// ensure aggregate names don't change:
// https://github.com/apache/arrow-datafusion/issues/3555
if matches!(expr, Expr::AggregateFunction { .. }) {
```
--
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 #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#issuecomment-1253939478
I wish I had a better story for you
--
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] thinkharderdev commented on a diff in pull request #3574: Fix logical plan serialization
Posted by GitBox <gi...@apache.org>.
thinkharderdev commented on code in PR #3574:
URL: https://github.com/apache/arrow-datafusion/pull/3574#discussion_r977447668
##########
datafusion/optimizer/src/type_coercion.rs:
##########
@@ -79,10 +79,29 @@ impl OptimizerRule for TypeCoercion {
const_evaluator,
};
+ let original_expr_names: Vec<Option<String>> = plan
+ .expressions()
+ .iter()
+ .map(|expr| expr.name().ok())
+ .collect();
+
let new_expr = plan
.expressions()
.into_iter()
- .map(|expr| expr.rewrite(&mut expr_rewrite))
+ .zip(original_expr_names)
+ .map(|(expr, original_name)| {
+ let expr = expr.rewrite(&mut expr_rewrite)?;
+
+ if matches!(expr, Expr::AggregateFunction { .. }) {
Review Comment:
Yeah, I agree
--
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