Skip to content

Commit e17612d

Browse files
committed
Revert "[SPARK-36429][SQL] JacksonParser should throw exception when data type unsupported"
### What changes were proposed in this pull request? This PR reverts the change in SPARK-36429 (#33654). See [conversation](#33654 (comment)). ### Why are the changes needed? To recover CIs. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? N/A Closes #33670 from sarutak/revert-SPARK-36429. Authored-by: Kousuke Saruta <[email protected]> Signed-off-by: Kousuke Saruta <[email protected]>
1 parent 888f8f0 commit e17612d

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,12 @@ class JacksonParser(
330330
case udt: UserDefinedType[_] =>
331331
makeConverter(udt.sqlType)
332332

333-
// We don't actually hit this exception though, we keep it for understandability
334-
case _ => throw QueryExecutionErrors.unsupportedTypeError(dataType)
333+
case _ =>
334+
(parser: JsonParser) =>
335+
// Here, we pass empty `PartialFunction` so that this case can be
336+
// handled as a failed conversion. It will throw an exception as
337+
// long as the value is not null.
338+
parseJsonToken[AnyRef](parser, dataType)(PartialFunction.empty[JsonToken, AnyRef])
335339
}
336340

337341
/**

sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp-ansi.sql.out

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,9 @@ You may get a different result due to the upgrading of Spark 3.0: Fail to recogn
661661
-- !query
662662
select from_json('{"t":"26/October/2015"}', 't Timestamp', map('timestampFormat', 'dd/MMMMM/yyyy'))
663663
-- !query schema
664-
struct<>
664+
struct<from_json({"t":"26/October/2015"}):struct<t:timestamp_ntz>>
665665
-- !query output
666-
java.lang.Exception
667-
Unsupported type: timestamp_ntz
666+
{"t":null}
668667

669668

670669
-- !query

sql/core/src/test/resources/sql-tests/results/timestampNTZ/timestamp.sql.out

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,9 @@ You may get a different result due to the upgrading of Spark 3.0: Fail to recogn
642642
-- !query
643643
select from_json('{"t":"26/October/2015"}', 't Timestamp', map('timestampFormat', 'dd/MMMMM/yyyy'))
644644
-- !query schema
645-
struct<>
645+
struct<from_json({"t":"26/October/2015"}):struct<t:timestamp_ntz>>
646646
-- !query output
647-
java.lang.Exception
648-
Unsupported type: timestamp_ntz
647+
{"t":null}
649648

650649

651650
-- !query

0 commit comments

Comments
 (0)