dssysolyatin commented on code in PR #2974:
URL: https://github.com/apache/calcite/pull/2974#discussion_r1063433097


##########
core/src/test/resources/sql/agg.iq:
##########
@@ -3467,4 +3467,38 @@ order by ename, deptno;
 
 !ok
 
+# Test cases for [CALCITE-5209] ArrayIndexOutOfBoundsException during 
SqlToRelConverter for group-by on `case`
+# having `in` expression predicates exceeding SqlRelConverter.Config 
InSubQueryThreshold
+!use scott
+select
+    case when deptno in (1, 2, 3, 4, 5) THEN 1 else 0 end
+from emp
+group by
+    case when deptno in (1, 2, 3, 4, 5) THEN 1 else 0 end;
+
++--------+
+| EXPR$0 |
++--------+
+|      0 |
++--------+
+(1 row)
+
+!ok
+
+!set insubquerythreshold 5
+select
+    case when deptno in (1, 2, 3, 4, 5) THEN 1 else 0 end

Review Comment:
   What about "Proper sub-query handling if it is used inside select list and 
group by" ?



##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -6374,10 +6390,13 @@ private static class SubQuery {
     final SqlNode node;
     final RelOptUtil.Logic logic;
     @Nullable RexNode expr;
+    final SqlImplementor.@Nullable Clause parentClause;

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to