You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/04/29 08:43:09 UTC
[GitHub] [calcite] rubenada opened a new pull request, #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
rubenada opened a new pull request, #2786:
URL: https://github.com/apache/calcite/pull/2786
[[CALCITE-5003](https://issues.apache.org/jira/browse/CALCITE-5003)] MergeUnion on types with different collators produces wrong result.
Make sure that all inputs are sorted in the same way, adding a projection in case the input's type collation is not the same as the union's.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] thomasrebele commented on a diff in pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
thomasrebele commented on code in PR #2786:
URL: https://github.com/apache/calcite/pull/2786#discussion_r862960896
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeUnionRule.java:
##########
@@ -90,9 +96,42 @@ public EnumerableMergeUnionRule(Config config) {
}
}
+ final RelBuilder builder = call.builder();
final List<RelNode> inputs = new ArrayList<>(unionInputsSize);
for (RelNode input : union.getInputs()) {
- final RelNode newInput = sort.copy(sort.getTraitSet(), input, collation, null, inputFetch);
+ // Check if type collations match, otherwise store it in this map to generate a cast later
+ // to guarantee that all inputs will be sorted in the same way
+ final Map<Integer, RelDataType> castMap = new HashMap<>();
Review Comment:
How about using a bit set instead of a map? The value is only used once and can easily be looked up again.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] thomasrebele commented on a diff in pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
thomasrebele commented on code in PR #2786:
URL: https://github.com/apache/calcite/pull/2786#discussion_r863649346
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeUnionRule.java:
##########
@@ -90,9 +96,42 @@ public EnumerableMergeUnionRule(Config config) {
}
}
+ final RelBuilder builder = call.builder();
final List<RelNode> inputs = new ArrayList<>(unionInputsSize);
for (RelNode input : union.getInputs()) {
- final RelNode newInput = sort.copy(sort.getTraitSet(), input, collation, null, inputFetch);
+ // Check if type collations match, otherwise store it in this map to generate a cast later
+ // to guarantee that all inputs will be sorted in the same way
+ final Map<Integer, RelDataType> castMap = new HashMap<>();
Review Comment:
The union.getRowType().getFieldList() could be factored out of the for-loop. I guess that it does not impact the performance much, so up to you to decide.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] rubenada merged pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
rubenada merged PR #2786:
URL: https://github.com/apache/calcite/pull/2786
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] rubenada commented on a diff in pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
rubenada commented on code in PR #2786:
URL: https://github.com/apache/calcite/pull/2786#discussion_r863001331
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeUnionRule.java:
##########
@@ -90,9 +96,42 @@ public EnumerableMergeUnionRule(Config config) {
}
}
+ final RelBuilder builder = call.builder();
final List<RelNode> inputs = new ArrayList<>(unionInputsSize);
for (RelNode input : union.getInputs()) {
- final RelNode newInput = sort.copy(sort.getTraitSet(), input, collation, null, inputFetch);
+ // Check if type collations match, otherwise store it in this map to generate a cast later
+ // to guarantee that all inputs will be sorted in the same way
+ final Map<Integer, RelDataType> castMap = new HashMap<>();
Review Comment:
Makes sense. Change applied.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] rubenada commented on a diff in pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
rubenada commented on code in PR #2786:
URL: https://github.com/apache/calcite/pull/2786#discussion_r863659870
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeUnionRule.java:
##########
@@ -90,9 +96,42 @@ public EnumerableMergeUnionRule(Config config) {
}
}
+ final RelBuilder builder = call.builder();
final List<RelNode> inputs = new ArrayList<>(unionInputsSize);
for (RelNode input : union.getInputs()) {
- final RelNode newInput = sort.copy(sort.getTraitSet(), input, collation, null, inputFetch);
+ // Check if type collations match, otherwise store it in this map to generate a cast later
+ // to guarantee that all inputs will be sorted in the same way
+ final Map<Integer, RelDataType> castMap = new HashMap<>();
Review Comment:
ok, done.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] rubenada commented on pull request #2786: [CALCITE-5003] MergeUnion on types with different collators produces wrong result
Posted by GitBox <gi...@apache.org>.
rubenada commented on PR #2786:
URL: https://github.com/apache/calcite/pull/2786#issuecomment-1115963978
Thanks for the review @thomasrebele !
I plan to merge the patch in the coming days, if no objection appears.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org