Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-27790 Support ANSI SQL INTERVAL types
  3. SPARK-35998

Make from_csv/to_csv to handle year-month intervals properly

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.2.0, 3.3.0
    • 3.2.0
    • SQL
    • None

    Description

      from_csv throws exception if year-month interval types are given.

      spark-sql> select from_csv("interval '1-2' year to month", "a interval year to month");
      21/07/03 04:32:24 ERROR SparkSQLDriver: Failed in [select from_csv("interval '1-2' year to month", "a interval year to month")]
      java.lang.Exception: Unsupported type: interval year to month
      	at org.apache.spark.sql.errors.QueryExecutionErrors$.unsupportedTypeError(QueryExecutionErrors.scala:775)
      	at org.apache.spark.sql.catalyst.csv.UnivocityParser.makeConverter(UnivocityParser.scala:224)
      	at org.apache.spark.sql.catalyst.csv.UnivocityParser.$anonfun$valueConverters$1(UnivocityParser.scala:134)
      

      Also, to_csv doesn't handle year-month interval types properly though any exception is thrown.
      The result of to_csv for year-month interval types is not ANSI interval compliant form.

      spark-sql> select to_csv(named_struct("a", interval '1-2' year to month));
      14
      

      The result above should be INTERVAL '1-2' YEAR TO MONTH.

      Attachments

        Activity

          People

            sarutak Kousuke Saruta
            sarutak Kousuke Saruta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: