Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] JsonToStructs and ScanJson should invalidate the entire array on overflow #10573

Open
revans2 opened this issue Mar 12, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@revans2
Copy link
Collaborator

revans2 commented Mar 12, 2024

Is your feature request related to a problem? Please describe.

Right now when parsing an array of longs/ints/etc. If there is an overflow, we only invalidate the bad value, but Spark will invalidate the entire array.

 val df = Seq("""{"data": [9223372036854775807,-9223372036854775808]}}""","""{"data": [9223372036854775808, -9223372036854775809]}""","""{"data": [99999999999999999999999999999999999999, -99999999999999999999999999999999999999]}""", """{"data":[1,2,3,4,5,9223372036854775808]}""").toDF("json")

spark.conf.set("spark.rapids.sql.enabled", false)

df.repartition(1).selectExpr("from_json(json, 'data ARRAY<LONG>')").show(false)
+---------------------------------------------+
|from_json(json)                              |
+---------------------------------------------+
|{[9223372036854775807, -9223372036854775808]}|
|{null}                                       |
|{null}                                       |
|{null}                                       |
+---------------------------------------------+

spark.conf.set("spark.rapids.sql.enabled", true)
spark.conf.set("spark.rapids.sql.expression.JsonToStructs", true)

df.repartition(1).selectExpr("from_json(json, 'data ARRAY<LONG>')").show(false)
+---------------------------------------------+
|from_json(json)                              |
+---------------------------------------------+
|{[9223372036854775807, -9223372036854775808]}|
|{[null, null]}                               |
|{[null, null]}                               |
|{[1, 2, 3, 4, 5, null]}                      |
+---------------------------------------------+

We should try to match what Spark does.

@revans2 revans2 added feature request New feature or request ? - Needs Triage Need team to review and classify labels Mar 12, 2024
@mattahrens mattahrens removed the ? - Needs Triage Need team to review and classify label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants