IGNITE-20164 Sql. Incorrect propagation of RelCollation trait for Sort-based map/reduce aggregates#2461
Conversation
79208fe to
f2285cc
Compare
| * @see org.apache.calcite.rel.core.AggregateCall#transform(TargetMapping) | ||
| */ | ||
| public static Mappings.TargetMapping trimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { | ||
| public static Mapping trimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { |
There was a problem hiding this comment.
Mappings.apply(mapping, ImmutableBitSet) accepts Mapping instead of Mappings.TargetMapping.
| * @see #trimmingMapping(int, ImmutableBitSet) | ||
| */ | ||
| public static Mappings.TargetMapping inverseTrimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { | ||
| public static Mapping inverseTrimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { |
There was a problem hiding this comment.
To have access to getSource in PlanUtils::createHashAggRowType
5f26578 to
636730b
Compare
| */ | ||
| public static Mappings.TargetMapping trimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { | ||
| public static Mapping trimmingMapping(int sourceSize, ImmutableBitSet requiredElements) { | ||
| Mapping mapping = Mappings.create(MappingType.PARTIAL_FUNCTION, sourceSize, requiredElements.cardinality()); |
There was a problem hiding this comment.
If you don't mind, let's change PARTIAL_FUNCTION to INVERSE_SURJECTION. That way we can get rid of inverseTrimmingMapping method, because created mapping start to work both ways
| @MethodSource("provideRules") | ||
| public void testAggDistinctGroupSet(String[] rules) { | ||
| try { | ||
| sql("CREATE TABLE testMe (id INTEGER PRIMARY KEY, a INTEGER, b INTEGER);"); |
There was a problem hiding this comment.
do we really need to create new table here? Currently, creation of a new table is a pretty time consuming operation (it takes about 10sec on my laptop). Does it make sense to use any table from initTestData?
There was a problem hiding this comment.
Moved all CREATE TABLE statements in this file to initTestData.
| * </pre> | ||
| * | ||
| * <p>Otherwise this operator is unable to fully satisfy required ordering and we require collation trait based | ||
| * columns from the grouping set, and the rest of of the requirements is going to be satisfied by enforcer operator: |
There was a problem hiding this comment.
| * columns from the grouping set, and the rest of of the requirements is going to be satisfied by enforcer operator: | |
| * columns from the grouping set, and the rest of the requirements is going to be satisfied by enforcer operator: |
| * </pre> | ||
| * | ||
| * @param nodeTraits Required relational node output traits. | ||
| * @param inputTraits Required relational node input traits. |
There was a problem hiding this comment.
that is not required traits but actual traits of the input
methods for pass through and derive have similar signature, but different semantic:
- for pass through we are saying "hey, we want you to satisfy
nodeTraits. Btw, here is your input, do you want to adjust it as well?" - for derive we are saying "hey, let's see what your child is offering to you (
inputTraits). Btw, it's you (nodeTraits)"
| agg.getGroupSet(), | ||
| agg.getGroupSets(), | ||
| outTraits.replace(IgniteDistributions.single()), | ||
| convert(map, inTraits.replace(IgniteDistributions.single())), |
There was a problem hiding this comment.
I would say, input of reduce phase should have the same traits as its output
| * | ||
| * <p>Distribution hash(0) | ||
| */ | ||
| CASE_24_1A("SELECT COUNT(val0), COUNT(DISTINCT(val1)) from test", schema(hash())) |
There was a problem hiding this comment.
Let's also check plans for hash distribution: hash(val1)
There was a problem hiding this comment.
Added test cases for both hash(val0) and hash(val1).
…rt-based map/reduce aggregates
…rt-based map/reduce aggregates Aggregate planner tests: Add test cases for identity distribution.
…rt-based map/reduce aggregates Fix checkstyle issues.
Updates grouping set columns on REDUCE phase of a sort aggregate to fix collation propagation.
Commons::trimmingMapping.Commons::trimmingMappingto useMappingType.INVERSE_SURJECTIONto make usage ofCommons::inverseTrimmingMappingredundant becausetrimmingMapping::getSourcereturns the same values.https://issues.apache.org/jira/browse/IGNITE-20164
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
The Review Checklist
- There is a single JIRA ticket related to the pull request.
- The web-link to the pull request is attached to the JIRA ticket.
- The JIRA ticket has the Patch Available state.
- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
Notes