Kevin Zhang created CALCITE-3603:
------------------------------------

             Summary: SqlLateralOperator's unparse add additional keyword 
'LATERAL' when the inner operator is SqlSnapshot
                 Key: CALCITE-3603
                 URL: https://issues.apache.org/jira/browse/CALCITE-3603
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.21.0
            Reporter: Kevin Zhang


When joining with a dimension table using the following sql

{code:sql}
SELECT
  o.amout, o.currency, r.rate, o.amount * r.rate
FROM
  Orders AS o
  JOIN LatestRates FOR SYSTEM_TIME AS OF o.proctime AS r
  ON r.currency = o.currency
{code}

the unparsed sql is:

{code:sql}
SELECT `o`.`amout`, `o`.`currency`, `r`.`rate`, `o`.`amount` * `r`.`rate`
FROM `Orders` AS `o`
INNER JOIN LATERAL `LatestRates` FOR SYSTEM_TIME AS OF `o`.`proctime` AS `r` ON 
`r`.`currency` = `o`.`currency`
{code}
which has a syntax error because an additional "LATERAL" is added after "JOIN".

The problem lies in SqlLateralOperator's unparse method, if the kind of the 
first operand is SqlSnapshot, we should not write out the operator's name.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to