diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java index 910cedc8d1457..112fd30c24bdf 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/exp/ExpressionFactoryImpl.java @@ -568,6 +568,7 @@ private String digest(List nodes, RelDataType type, boolean biParam) { new RexShuttle() { @Override public RexNode visitFieldAccess(RexFieldAccess fieldAccess) { b.append(", fldIdx=").append(fieldAccess.getField().getIndex()); + b.append(", fldType=").append(fieldAccess.getField().getType().getFullTypeString()); return super.visitFieldAccess(fieldAccess); } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java index 3e144df280005..b1d8fc330b40f 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/CorrelatesIntegrationTest.java @@ -37,6 +37,29 @@ public void testCorrelatesAssignedBeforeAccess() { .check(); } + /** + * Check compiled expression cache correctness for correlated variables with different data types. + */ + @Test + public void testCorrelatesDifferentDataType() { + for (String type : new String[] {"INTEGER", "TINYINT"}) { + try { + sql("CREATE TABLE t1(v INTEGER)"); + sql("CREATE TABLE t2(v " + type + ")"); + sql("INSERT INTO t1 VALUES (1)"); + sql("INSERT INTO t2 VALUES (1)"); + + assertQuery("SELECT (SELECT t1.v + t2.v FROM t1) FROM t2") + .returns(2) + .check(); + } + finally { + sql("DROP TABLE t1"); + sql("DROP TABLE t2"); + } + } + } + /** * Checks that correlates can't be moved under the table spool. */