Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3603

SqlLateralOperator's unparse add additional keyword 'LATERAL' when the inner operator is SqlSnapshot

    XMLWordPrintableJSON

    Details

      Description

      When joining with a dimension table using the following 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
      

      the unparsed sql is:

      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`
      

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                danny0405 Danny Chen
                Reporter:
                KevinZwx Kevin Zhang
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m