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

Add support for SqlWindowTableFunction in RelToSql Converter

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.39.0
    • core

    Description

      Converting the `RelNode` with `SqlWindowTableFunction` will fail with exception:

      For example the employee table:

       

        Column   |              Type              |
      -----------+-------------------------------
       id             | integer                   | 
       salary      | double precision             |  
       hire_rate | timestamp(0) without time zone |
       
      

      and the sql:

      SELECT * FROM TABLE(TUMBLE(TABLE employee, DESCRIPTOR(hire_date), INTERVAL '1' MINUTE))

      Conver it to RelNode like this:

      LogicalProject
      |
      | -- inputs:               <-----------    
      |     |--- LogicalTableScan           |    
      |                                     |    
      |-- RexCall:                          |    
      |    |- op: SqlWindowFunction         |    
      |    |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]   
      |
      |--- fieldList [`id`, `salary`, `hire_date`, `window_start`, `window_end`]

      When convert the RelNode to SqlNode, the operand( INPUT_REF(2))  of operator `DESCRIPTOR` incorrectly refers to the  RelNode (TableScan) in current implemention,  it should refer to input rows:

      LogicalProject
      |- 
      | -- inputs: 
      |      |--- LogicalTableScan 
      |     
      |-- RexCall: 
      |     |- op: SqlWindowFunction  
      |     |- operands: [DESCRIPTOR(INPUT_REF(2)), INTERVAL]
      |                                        |
      |                                        |
      |                                        \/
      |--- fieldList [`id`, `salary`,  `hire_date`, `window_start`, `window_end`] 

       

      Attachments

        Activity

          People

            ehds Dongsheng He
            ehds Dongsheng He
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: