You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2021/08/14 08:10:00 UTC
[jira] [Assigned] (SPARK-36491) Make from_json/to_json to handle
timestamp_ntz type properly
[ https://issues.apache.org/jira/browse/SPARK-36491?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Apache Spark reassigned SPARK-36491:
------------------------------------
Assignee: Kousuke Saruta (was: Apache Spark)
> Make from_json/to_json to handle timestamp_ntz type properly
> ------------------------------------------------------------
>
> Key: SPARK-36491
> URL: https://issues.apache.org/jira/browse/SPARK-36491
> Project: Spark
> Issue Type: Sub-task
> Components: SQL
> Affects Versions: 3.3.0
> Reporter: Kousuke Saruta
> Assignee: Kousuke Saruta
> Priority: Major
>
> In the current master, to_json/from_json can handle timestamp type like as follows.
> {code:java}
> SELECT to_json(map("a", TIMESTAMP"2021-11-23 11:22:33"));
> {"a":"2021-11-23T11:22:33.000+09:00"}
> {code}
> {code:java}
> SELECT from_json('{"a":"2021-11-23 11:22:33"}', "a TIMESTAMP");
> {"a":2021-11-23 11:22:33}
> {code}
> But they cannot handle timestamp_ntz type properly.
> {code:java}
> SELECT to_json(map("a", TIMESTAMP_NTZ"2021-11-23 11:22:33"));
> 21/08/12 16:14:07 ERROR SparkSQLDriver: Failed in [SELECT to_json(map("a", TIMESTAMP_NTZ"2021-11-23 11:22:33"))]
> java.lang.RuntimeException: Failed to convert value 1637666553000000 (class of class java.lang.Long) with the type of TimestampNTZType to JSON.
> at org.apache.spark.sql.errors.QueryExecutionErrors$.failToConvertValueToJsonError(QueryExecutionErrors.scala:294)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.$anonfun$makeWriter$25(JacksonGenerator.scala:201)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.$anonfun$makeWriter$25$adapted(JacksonGenerator.scala:199)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.writeMapData(JacksonGenerator.scala:253)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.$anonfun$write$3(JacksonGenerator.scala:293)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.writeObject(JacksonGenerator.scala:206)
> at org.apache.spark.sql.catalyst.json.JacksonGenerator.write(JacksonGenerator.scala:292)
> {code}
> {code:java}
> SELECT from_json('{"a":"2021-11-23 11:22:33"}', "a TIMESTAMP_NTZ");
> 21/08/12 16:16:00 ERROR SparkSQLDriver: Failed in [SELECT from_json('{"a":"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.json.JacksonParser.makeConverter(JacksonParser.scala:339)
> at org.apache.spark.sql.catalyst.json.JacksonParser.$anonfun$makeConverter$17(JacksonParser.scala:313)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org