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

Return type of PERCENTILE_DISC should be the same as sort expression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.33.0
    • None

    Description

      In the following expression:

      PERCENTILE_DISC ( numeric_literal ) WITHIN GROUP ( ORDER BY order_by_expression) 

      the return type of `PERCENTILE_DISC` aggregate function is hard-coded as `DOUBLE`, 
      while in Postgresql and MSSQL it is determined by the `order_by_expression` type. 

      Currently there is no way to derive the correct type of `PERCENTILE_DISC` function from the `order_by_expression` type, as this expression is not an argument for the `PERCENTILE_DISC` function. 

      Calcite is creating the following tree from this expression:

      SqlCall(operator: WITHING_GROUP, operands: [SqlCall( operator: PERCENTILE_DISC, operands: [numeric_literal], order_by_expression])

      for correct type derivation, the order_by_expression should be an operand of the PERCENTILE_DISC call

      Attachments

        Issue Links

          Activity

            People

              itiels Itiel Sadeh
              itiels Itiel Sadeh
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 2h 20m
                  2h 20m