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

Add SqlIdentifier conversion to ITEM operator for dynamic tables in ExtendedExpander

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.17.0
    • 1.18.0
    • None
    • None

    Description

      SqlIdentifier is not converted to ITEM operator for dynamic tables in ExtendedExpander and thus query returns wrong results. Happens when isGroupByAlias is set to true in SQL conformance.
      Query example:

      select n_regionkey, max(min(n_nationkey)) over(partition by n_regionkey)
      from (select * from SALES.NATION)
      group by n_regionkey
      

      Incorrect logical plan:

      LogicalProject(N_REGIONKEY=[ITEM($0, 'N_REGIONKEY')], EXPR$1=[MAX($1) OVER (PARTITION BY ITEM($0, 'N_REGIONKEY') RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)])
        LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
          LogicalProject(**=[$0], $f1=[ITEM($0, 'N_NATIONKEY')])
            LogicalProject(**=[$0])
              LogicalTableScan(table=[[CATALOG, SALES, NATION]])
      

      Correct logical plan:

      LogicalProject(N_REGIONKEY=[$0], EXPR$1=[MAX($1) OVER (PARTITION BY $0 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)])
        LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
          LogicalProject(N_REGIONKEY=[ITEM($0, 'N_REGIONKEY')], $f1=[ITEM($0, 'N_NATIONKEY')])
            LogicalProject(**=[$0])
              LogicalTableScan(table=[[CATALOG, SALES, NATION]])
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            julianhyde Julian Hyde
            arina Arina Ielchiieva
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment