File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
main/java/org/apache/ignite/internal/processors/query/calcite/rel
test/java/org/apache/ignite/internal/processors/query/calcite Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,16 @@ public IgniteFilter(RelInput input) {
171171 // Remap correlate fields to input fields.
172172 int corrFieldsCnt = ((RexNode )corr .getNode ()).getType ().getFieldCount ();
173173 int inputFieldsCnt = getRowType ().getFieldCount ();
174+
175+ // Calcite during planning sometimes can produce hash distribution for correlated nested loop joins
176+ // on keys which are not part of RexCorrelVariable type.
177+ // These keys can't be refered by RexFieldAccess and original hash distribution can't be restored,
178+ // so, just ignore correlated distribution with these keys.
179+ for (int i : corrDistr .getKeys ()) {
180+ if (i >= corrFieldsCnt )
181+ return null ;
182+ }
183+
174184 Mapping mapping = Mappings .create (MappingType .PARTIAL_FUNCTION , corrFieldsCnt , inputFieldsCnt );
175185
176186 List <RexNode > conds = RelOptUtil .conjunctions (RexUtil .toCnf (getCluster ().getRexBuilder (), condition ));
Original file line number Diff line number Diff line change 1818package org .apache .ignite .internal .processors .query .calcite .integration .tpch ;
1919
2020import org .apache .ignite .internal .processors .query .calcite .integration .AbstractBasicIntegrationTest ;
21- import org .junit .Ignore ;
2221import org .junit .Test ;
2322
2423/** */
@@ -27,7 +26,6 @@ public class TpchQ20Test extends AbstractBasicIntegrationTest {
2726 * Test the Q20 TPC-H query can be planned and executed.
2827 */
2928 @ Test
30- @ Ignore ("https://issues.apache.org/jira/browse/IGNITE-24730" )
3129 public void testQ20 () throws Exception {
3230 TpchHelper .createTables (client );
3331
Original file line number Diff line number Diff line change 3535import org .apache .ignite .internal .processors .query .calcite .prepare .IgnitePlanner ;
3636import org .apache .ignite .internal .processors .query .calcite .prepare .PlannerPhase ;
3737import org .apache .ignite .internal .processors .query .calcite .prepare .PlanningContext ;
38+ import org .apache .ignite .internal .processors .query .calcite .rel .AbstractIgniteJoin ;
3839import org .apache .ignite .internal .processors .query .calcite .rel .IgniteCorrelatedNestedLoopJoin ;
3940import org .apache .ignite .internal .processors .query .calcite .rel .IgniteExchange ;
4041import org .apache .ignite .internal .processors .query .calcite .rel .IgniteFilter ;
@@ -281,6 +282,14 @@ public void testCorrelatedDistribution() throws Exception {
281282 ")) FROM th1" ;
282283 assertPlan (sql , schema , colocatedPredicate );
283284
285+ // Correlate on top of another join.
286+ sql = "SELECT a FROM ta1 WHERE ta1.a IN (SELECT a FROM th1) AND EXISTS (SELECT 1 FROM ta2 WHERE ta2.b = ta1.a)" ;
287+ assertPlan (sql , schema , hasChildThat (isInstanceOf (IgniteCorrelatedNestedLoopJoin .class )
288+ .and (input (0 , isInstanceOf (AbstractIgniteJoin .class )))
289+ .and (input (1 , isInstanceOf (IgniteColocatedAggregateBase .class )
290+ .and (hasChildThat (isInstanceOf (IgniteExchange .class )).negate ())
291+ ))));
292+
284293 // Condition on not colocated column.
285294 sql = "SELECT a FROM ta1 WHERE EXISTS (SELECT a FROM ta2 WHERE ta2.a = ta1.a)" ;
286295 assertPlan (sql , schema , colocatedPredicate .negate ());
You can’t perform that action at this time.
0 commit comments