Skip to content

Commit 1939109

Browse files
committed
Fix test failure
Signed-off-by: Tomoyuki Morita <[email protected]>
1 parent 780c5de commit 1939109

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,12 +1257,12 @@ public RelNode visitJoin(Join node, CalcitePlanContext context) {
12571257
|| (node.getArgumentMap().get("overwrite").equals(Literal.TRUE))) {
12581258
toBeRemovedFields =
12591259
duplicatedFieldNames.stream()
1260-
.map(field -> JoinAndLookupUtils.analyzeFieldsInRight(field, context))
1260+
.map(field -> JoinAndLookupUtils.analyzeFieldsInLeft(field, context))
12611261
.toList();
12621262
} else {
12631263
toBeRemovedFields =
12641264
duplicatedFieldNames.stream()
1265-
.map(field -> JoinAndLookupUtils.analyzeFieldsInLeft(field, context))
1265+
.map(field -> JoinAndLookupUtils.analyzeFieldsInRight(field, context))
12661266
.toList();
12671267
}
12681268
Literal max = node.getArgumentMap().get("max");

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalciteDynamicFieldsJoinIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testJoinWithStaticField() throws IOException {
5252
"calcite:\n"
5353
+ " logical: |\n"
5454
+ " LogicalSystemLimit(fetch=[200], type=[QUERY_SIZE_LIMIT])\n"
55-
+ " LogicalProject(a1=[COALESCE(ITEM($5, 'a1'), $0)], a2=[$1], a3=[$4],"
55+
+ " LogicalProject(a1=[COALESCE(ITEM($5, 'a1'), $0)], a2=[$3], a3=[$4],"
5656
+ " a4=[ITEM(MAP_CONCAT($2, $5), 'a4')], a5=[ITEM(MAP_CONCAT($2, $5), 'a5')])\n"
5757
+ " LogicalJoin(condition=[=($1, $3)], joinType=[inner])\n"
5858
+ " LogicalProject(a1=[$0], a2=[$1], _MAP=[$8])\n"
@@ -64,7 +64,7 @@ public void testJoinWithStaticField() throws IOException {
6464
+ " EnumerableCalc(expr#0..5=[{inputs}], expr#6=['a1'], expr#7=[ITEM($t5, $t6)],"
6565
+ " expr#8=[COALESCE($t7, $t0)], expr#9=[MAP_CONCAT($t2, $t5)], expr#10=['a4'],"
6666
+ " expr#11=[ITEM($t9, $t10)], expr#12=['a5'], expr#13=[ITEM($t9, $t12)], a1=[$t8],"
67-
+ " a2=[$t1], a3=[$t4], a4=[$t11], a5=[$t13])\n"
67+
+ " a2=[$t3], a3=[$t4], a4=[$t11], a5=[$t13])\n"
6868
+ " EnumerableLimit(fetch=[200])\n"
6969
+ " EnumerableMergeJoin(condition=[=($1, $3)], joinType=[inner])\n"
7070
+ " EnumerableSort(sort0=[$1], dir0=[ASC])\n"
@@ -157,7 +157,7 @@ public void testJoinDynamicWithStatic() throws IOException {
157157
+ " EnumerableLimit(fetch=[50000])\n"
158158
+ " EnumerableCalc(expr#0..8=[{inputs}], a3=[$t1], _MAP=[$t8])\n"
159159
+ " CalciteEnumerableIndexScan(table=[[OpenSearch,"
160-
+ " test_dynamic_right]])");
160+
+ " test_dynamic_right]])\n");
161161

162162
JSONObject result = executeQuery(query);
163163
verifyJoinResult(result);
@@ -173,7 +173,7 @@ public void testJoinStaticWithDynamic() throws IOException {
173173
"calcite:\n"
174174
+ " logical: |\n"
175175
+ " LogicalSystemLimit(fetch=[200], type=[QUERY_SIZE_LIMIT])\n"
176-
+ " LogicalProject(a1=[COALESCE(ITEM($5, 'a1'), $0)], a2=[$1], a3=[$4],"
176+
+ " LogicalProject(a1=[COALESCE(ITEM($5, 'a1'), $0)], a2=[$3], a3=[$4],"
177177
+ " a4=[ITEM(MAP_CONCAT($2, $5), 'a4')], a5=[ITEM(MAP_CONCAT($2, $5), 'a5')])\n"
178178
+ " LogicalJoin(condition=[=($0, ITEM($5, 'a1'))], joinType=[inner])\n"
179179
+ " LogicalProject(a1=[$0], a2=[$1], _MAP=[$8])\n"
@@ -183,17 +183,17 @@ public void testJoinStaticWithDynamic() throws IOException {
183183
+ " CalciteLogicalIndexScan(table=[[OpenSearch, test_dynamic_right]])\n"
184184
+ " physical: |\n"
185185
+ " EnumerableCalc(expr#0..5=[{inputs}], expr#6=['a1'], expr#7=[ITEM($t4, $t6)],"
186-
+ " expr#8=[COALESCE($t7, $t0)], expr#9=[MAP_CONCAT($t2, $t4)], expr#10=['a4'],"
186+
+ " expr#8=[COALESCE($t7, $t0)], expr#9=[MAP_CONCAT($t1, $t4)], expr#10=['a4'],"
187187
+ " expr#11=[ITEM($t9, $t10)], expr#12=['a5'], expr#13=[ITEM($t9, $t12)], a1=[$t8],"
188-
+ " a2=[$t1], a3=[$t3], a4=[$t11], a5=[$t13])\n"
188+
+ " a2=[$t2], a3=[$t3], a4=[$t11], a5=[$t13])\n"
189189
+ " EnumerableLimit(fetch=[200])\n"
190190
+ " EnumerableMergeJoin(condition=[=($0, $5)], joinType=[inner])\n"
191191
+ " EnumerableSort(sort0=[$0], dir0=[ASC])\n"
192-
+ " EnumerableCalc(expr#0..8=[{inputs}], proj#0..1=[{exprs}], _MAP=[$t8])\n"
192+
+ " EnumerableCalc(expr#0..8=[{inputs}], a1=[$t0], _MAP=[$t8])\n"
193193
+ " CalciteEnumerableIndexScan(table=[[OpenSearch, test_dynamic_left]])\n"
194-
+ " EnumerableSort(sort0=[$2], dir0=[ASC])\n"
194+
+ " EnumerableSort(sort0=[$3], dir0=[ASC])\n"
195195
+ " EnumerableCalc(expr#0..8=[{inputs}], expr#9=['a1'], expr#10=[ITEM($t8,"
196-
+ " $t9)], a3=[$t1], _MAP=[$t8], $f2=[$t10])\n"
196+
+ " $t9)], proj#0..1=[{exprs}], _MAP=[$t8], $f3=[$t10])\n"
197197
+ " EnumerableLimit(fetch=[50000])\n"
198198
+ " CalciteEnumerableIndexScan(table=[[OpenSearch,"
199199
+ " test_dynamic_right]])\n");

0 commit comments

Comments
 (0)