Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-6378

MajorType passed into UDF with FieldReader has unset prec, scale for DECIMAL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.13.0
    • None
    • None
    • None

    Description

      UDFs allow passing in a generic FieldReader such as for the typeof function. I tried to modify the new sqlTypeOf() function to include the DECIMAL precision and scale, something like: DECIMAL(9, 2).

      But, the MajorType associated with the FieldReader has these values as 0. Not sure if it is because the DECIMAL is the result of a cast, or if there is a deeper bug.

      Query:

      ALTER SESSION SET `planner.enable_decimal_data_type` = true;
      
      SELECT sqlTypeof(CAST(a AS DECIMAL)) FROM (VALUES (1)) AS T(a);
      

      Debug information for the MajorType

      type	TypeProtos$MajorType  (id=151)	
      precision_	0	
      scale_	0	
      

      This bug is not simply a nuisance for formatting. The precision and scale are required to make sense of any DECIMAL values that the function wants to process: without these values, the function does not know the meaning of the DECIMAL data.

      Once this bug is fixed, reenable the type suffix code in UnionFunctions.extendType().

      Attachments

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              paul-rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: