Julian Hyde created CALCITE-6833:
------------------------------------

             Summary: JDBC adapter generates invalid table alias for semi-join 
in UNION
                 Key: CALCITE-6833
                 URL: https://issues.apache.org/jira/browse/CALCITE-6833
             Project: Calcite
          Issue Type: Bug
            Reporter: Julian Hyde


Following CALCITE-5395, the test 
[RelToSqlConverterTest.testUnionUnderSemiJoinNode|https://github.com/apache/calcite/blob/2ddfb0eb00bd87b040e4ca743a7451034dd28f98/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java#L1783],
  generates the following query, which is invalid.

{code}
SELECT "DEPTNO"
FROM (SELECT *
  FROM (SELECT *
    FROM "scott"."EMP"
    UNION ALL
    SELECT *
    FROM "scott"."EMP")
  WHERE EXISTS (SELECT 1
    FROM "scott"."DEPT"
    WHERE "t"."DEPTNO" = "DEPT"."DEPTNO")) AS "t";
{code}

The query is invalid because the table alias "t" is used in a scope where it is 
not visible. I suspect that {{AS "t"}} should be at the end of line 7, not line 
11.

{{RelToSqlConverterTest}} correctly gives a validation error
{noformat}
>From line 10, column 7 to line 10, column 9: Table 't' not found
{noformat}
Validation is only now enabled, during development of a fix for CALCITE-5529.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to