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

SUM function does not work against interval data type from csv or json files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Functions - Drill

    Description

      I have a csv table with the following interval year data:
      select columns[1] from `interval_data.csv`;
      ---------

      EXPR$0

      ---------

      P12Y
      P152Y
      P-152Y
      P5Y
      P10Y
      P0Y
      P-50Y
      P12Y
      P152Y

      ---------

      I got an exception when trying to use the SUM function against the data:
      select sum(cast(columns[1] as interval year)) from `interval_data.csv`;
      Error: VALIDATION ERROR: From line 1, column 8 to line 1, column 45: Cannot apply 'SUM' to arguments of type 'SUM(<INTERVAL YEAR>)'. Supported form(s): 'SUM(<NUMERIC>)'

      Same error is encountered for same data from JSON file.
      This works for interval data from parquet file:
      ./parquet-schema ../interval_data.parquet
      message root {
      optional int32 c_row;
      optional fixed_len_byte_array(12) c_interval_year;
      optional fixed_len_byte_array(12) c_interval_month;
      optional fixed_len_byte_array(12) c_interval_day;
      optional fixed_len_byte_array(12) c_interval_hour;
      optional fixed_len_byte_array(12) c_interval_minute;
      optional fixed_len_byte_array(12) c_interval_second;
      optional binary c_interval (UTF8);
      optional int32 c_time;
      optional int32 c_date;
      optional int64 c_timestamp;
      }

      select sum(c_interval_year) from `interval_data.parquet`;
      ---------

      EXPR$0

      ---------

      P1692M

      ---------

      Attachments

        Activity

          People

            Unassigned Unassigned
            knguyen Krystal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: