Skip to content

Commit

Permalink
IGNITE-23435 SQL Calcite: Fix compiled expression cache key for corre…
Browse files Browse the repository at this point in the history
…lated variable (#11593)
  • Loading branch information
alex-plekhanov authored Oct 15, 2024
1 parent 4b5b251 commit e948408
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ private String digest(List<RexNode> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit e948408

Please sign in to comment.