Skip to content

Commit 049a7fb

Browse files
committed
Move num-of-column check of in subquery ahead from RexSubQuery.java#L78 because assert is disabled in production
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 1977083 commit 049a7fb

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,22 @@ public RexNode visitInSubquery(InSubquery node, CalcitePlanContext context) {
539539
List<RexNode> nodes = node.getChild().stream().map(child -> analyze(child, context)).toList();
540540
UnresolvedPlan subquery = node.getQuery();
541541
RelNode subqueryRel = resolveSubqueryPlan(subquery, context);
542-
try {
543-
return context.relBuilder.in(subqueryRel, nodes);
544-
// TODO
545-
// The {@link org.apache.calcite.tools.RelBuilder#in(RexNode,java.util.function.Function)}
546-
// only support one expression. Change to follow code after calcite fixed.
547-
// return context.relBuilder.in(
548-
// nodes.getFirst(),
549-
// b -> {
550-
// RelNode subqueryRel = subquery.accept(planVisitor, context);
551-
// b.build();
552-
// return subqueryRel;
553-
// });
554-
} catch (AssertionError e) {
542+
if (subqueryRel.getRowType().getFieldCount() != nodes.size()) {
555543
throw new SemanticCheckException(
556544
"The number of columns in the left hand side of an IN subquery does not match the number"
557545
+ " of columns in the output of subquery");
558546
}
547+
// TODO
548+
// The {@link org.apache.calcite.tools.RelBuilder#in(RexNode,java.util.function.Function)}
549+
// only support one expression. Change to follow code after calcite fixed.
550+
// return context.relBuilder.in(
551+
// nodes.getFirst(),
552+
// b -> {
553+
// RelNode subqueryRel = subquery.accept(planVisitor, context);
554+
// b.build();
555+
// return subqueryRel;
556+
// });
557+
return context.relBuilder.in(subqueryRel, nodes);
559558
}
560559

561560
@Override

0 commit comments

Comments
 (0)