Haris Sattar created CALCITE-7508:
-------------------------------------
Summary: RelToSqlConverter registers wrong alias for correlation
variable in visit(Project)
Key: CALCITE-7508
URL: https://issues.apache.org/jira/browse/CALCITE-7508
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.39.0
Reporter: Haris Sattar
*Example:*
Input RelNode tree: a correlated scalar subquery where the outer table is
table_a and the inner table is table_b, correlated on column "id".
*Expected SQL output:*
SELECT "id",
(SELECT SUM("value") FROM "table_b" AS "t1"
WHERE "id" = "t"."id") AS "total_value"
FROM "table_a" AS "t"
*Actual SQL output:*
SELECT "id",
(SELECT SUM("value") FROM "table_b" AS "t1"
WHERE "id" = "t0"."id") AS "total_value"
FROM "table_a" AS "t"
The correlation reference emits "t0"."id" but the outer table's FROM clause
says AS "t". "t0" does not exist in the query. The SQL is invalid and will be
rejected by the execution engine.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)