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

IGNORE NULLS / RESPECT NULLS window function option can result in a type validation error in SqlToRelConverter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      If the IGNORE NULLS / RESPECT NULLS window function option is used when the input to the window function is a non-nullable type and the window frame is of type ROWS with an offset based lower or upper bound (i.e., n PRECEDING / FOLLOWING), this results in an error here - the inferred return type for the window function from the parsed SqlNode is a non-nullable type but the converted type is nullable (which makes sense since the result should be null for rows where the window frame is "out of bounds").

       

      This issue does not occur if any of the following conditions are true:

      • IGNORE NULLS / RESPECT NULLS options are not specified because in this case the inferred return type for the window function call in the parsed SqlNode is also a nullable type.
      • The input to the window function is a nullable type.
      • Both the window frame bounds are UNBOUNDED PRECEDING / CURRENT ROW / UNBOUNDED FOLLOWING 

       

      While it likely doesn't make much sense for users to specify these options when the window function's input type is non-nullable, it should ideally not result in an arcane error like:

      Caused by: java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
      validated type:
      RecordType(... INTEGER NOT NULL EXPR$3) NOT NULL
      converted type:
      RecordType(... INTEGER EXPR$3) NOT NULL)

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            yash.mayya Yash Mayya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: