Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-35662 Support Timestamp without time zone data type
  3. SPARK-36490

Make from_csv/to_csv to handle timestamp_ntz type properly

    XMLWordPrintableJSON

Details

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

    Description

      In the current master, to_csv/from_csv can handle timestamp type like as follows.

      SELECT to_csv(struct(TIMESTAMP"2021-11-23 11:22:33")); 
      2021-11-23T11:22:33.000+09:00
      
      SELECT from_csv("2021-11-23 11:22:33", "a TIMESTAMP"); 
      {"a":2021-11-23 11:22:33}
      

      But they cannot handle timestamp_ntz type properly.

      SELECT to_csv(struct(TIMESTAMP_NTZ"2021-11-23 11:22:33"));
      -- 2021-11-23T11:22:33.000 is expected.
      1637666553000000
      
      SELECT from_csv("2021-11-23 11:22:33", "a TIMESTAMP_NTZ");
      21/08/12 16:12:49 ERROR SparkSQLDriver: Failed in [SELECT from_csv("2021-11-23 11:22:33", "a TIMESTAMP_NTZ")]
      java.lang.Exception: Unsupported type: timestamp_ntz
              at org.apache.spark.sql.errors.QueryExecutionErrors$.unsupportedTypeError(QueryExecutionErrors.scala:777)
              at org.apache.spark.sql.catalyst.csv.UnivocityParser.makeConverter(UnivocityParser.scala:234)
              at org.apache.spark.sql.catalyst.csv.UnivocityParser.$anonfun$valueConverters$1(UnivocityParser.scala:134)
      

      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: