mihaibudiu commented on code in PR #3899:
URL: https://github.com/apache/calcite/pull/3899#discussion_r1702491023
##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -3812,4 +3812,242 @@ WHERE s1.total > (SELECT avg(total) FROM agg_sal s2
WHERE s1.deptno = s2.deptno)
!ok
+# [CALCITE-6506] Type inference for IN list is incorrect
+
+# Test LHS is no nullable and RHS is no nullable
Review Comment:
"not nullable" sounds better
##########
core/src/test/resources/sql/sub-query.iq:
##########
@@ -3812,4 +3812,242 @@ WHERE s1.total > (SELECT avg(total) FROM agg_sal s2
WHERE s1.deptno = s2.deptno)
!ok
+# [CALCITE-6506] Type inference for IN list is incorrect
+
+# Test LHS is no nullable and RHS is no nullable
+select empno, empno in (7369, 7499, 7521) from emp;
++-------+--------+
+| EMPNO | EXPR$1 |
++-------+--------+
+| 7369 | true |
+| 7499 | true |
+| 7521 | true |
+| 7566 | false |
+| 7654 | false |
+| 7698 | false |
+| 7782 | false |
+| 7788 | false |
+| 7839 | false |
+| 7844 | false |
+| 7876 | false |
+| 7900 | false |
+| 7902 | false |
+| 7934 | false |
++-------+--------+
+(14 rows)
+
+!ok
+
+
+EnumerableCalc(expr#0..5=[{inputs}], expr#6=[IS NOT NULL($t5)],
expr#7=[0:BIGINT], expr#8=[<>($t1, $t7)], expr#9=[AND($t6, $t8)],
expr#10=[<($t2, $t1)], expr#11=[null:BOOLEAN], expr#12=[IS NULL($t5)],
expr#13=[AND($t10, $t11, $t8, $t12)], expr#14=[OR($t9, $t13)],
expr#15=[CAST($t14):BOOLEAN NOT NULL], EMPNO=[$t0], EXPR$1=[$t15])
Review Comment:
this is a very complicated plan!
you would think a simpler one could be generated using SEARCH
##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java:
##########
@@ -330,6 +330,10 @@ public static boolean containsNullable(RelDataType type) {
public static RelDataType keepSourceTypeAndTargetNullability(RelDataType
sourceRelDataType,
RelDataType targetRelDataType,
RelDataTypeFactory typeFactory) {
+ checkArgument(
+ (targetRelDataType.isStruct() && sourceRelDataType.isStruct())
+ || (!targetRelDataType.isStruct() &&
!sourceRelDataType.isStruct()),
+ "Input sourceRelDataType and targetRelDataType must have same struct
type");
Review Comment:
I think that a better message is "one is a struct, while the other one is
not".
"same struct type" implies that the type must be exactly the same.
--
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]