From 5db605fe23c536cabdac113cdb20322f9acce87d Mon Sep 17 00:00:00 2001 From: Ulrich Kramer Date: Mon, 27 May 2024 11:22:14 +0200 Subject: [PATCH] EXPB-2218 Prune right relation of left join in case of distinct aggregation --- .../main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java b/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java index a07801931ad..853feb58b50 100644 --- a/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java +++ b/core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java @@ -798,8 +798,8 @@ public TrimResult trimFields( TrimResult result = trimChild(join, join.getLeft(), fieldsUsed, extraFields); Mapping mapping = result.right; Mapping mapping2 = Mappings.create(MappingType.INVERSE_SURJECTION,join.getRowType().getFieldCount(),mapping.getTargetCount()); - for ( int i = 0 ; i < mapping.getTargetCount(); i++) { - mapping2.set(i,mapping.getTarget(i)); + for ( IntPair map : mapping) { + mapping2.set(map.source,map.target); } return new TrimResult(result.left,mapping2); }