Wenrui Meng created CALCITE-6007:
------------------------------------

             Summary: Sqlwith as subquery without alias doesn't have correct 
alias setup
                 Key: CALCITE-6007
                 URL: https://issues.apache.org/jira/browse/CALCITE-6007
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.35.0, 1.34.0
            Reporter: Wenrui Meng



{code:java}
SELECT
  a,
  b
FROM (
  WITH
    sub AS (
    SELECT
      1 AS a,
      2 AS b)
  SELECT
    *
  FROM
    sub)
WHERE
  a IS NOT null

{code}

It will generate the following SQL statement after validation


{code:java}
SELECT
  EXPR$0.a,
  EXPR$0.b
FROM (
  WITH
    sub AS (
    SELECT
      1 AS a,
      2 AS b)
  SELECT
    sub.a AS a, sub.b AS b
  FROM
    sub)
WHERE
  EXPR$0.a IS NOT null

{code}

The validated SQL become invalid since there is no EXPR$0 alias append for the 
SqlWith sub query but used in the expression outside. 



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

Reply via email to