You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "tianhanhu (via GitHub)" <gi...@apache.org> on 2025/06/20 18:46:55 UTC
[PR] [SPARK-52544] Allow configuring Json datasource string length limit through SQLConf [spark]
tianhanhu opened a new pull request, #51235:
URL: https://github.com/apache/spark/pull/51235
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
In https://issues.apache.org/jira/browse/SPARK-43263, Spark upgraded Jackson to 2.15.0. This brought in a breaking change that set string max length to 20,000 which Json data source picked up. Before the upgrade, there was no limit. The limit could only be modified through Json option "maxStringLen".
This PR attempts to restore the old no limit behavior, by introducing a new JSON_MAX_STRING_LENGTH feature flag that sets the string length limit globally.
### Why are the changes needed?
To restore the old string length limit behavior of Json connector, prior to the upgrade to Jackson 2.15.0.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes, added a new user configurable config for specifying max string length for Json connector.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
New unit tests.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cdagraca (via GitHub)" <gi...@apache.org>.
cdagraca commented on PR #51235:
URL: https://github.com/apache/spark/pull/51235#issuecomment-3117492374
It looks like FasterXML have increased the size on their end (https://github.com/FasterXML/jackson-core/issues/1014, https://github.com/FasterXML/jackson-core/pull/1019)
Could updating to a more recent version of that library be a simpler fix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cdagraca (via GitHub)" <gi...@apache.org>.
cdagraca commented on code in PR #51235:
URL: https://github.com/apache/spark/pull/51235#discussion_r2263130135
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala:
##########
@@ -4096,6 +4096,49 @@ abstract class JsonSuite
Row("{null, bad json}"), Row("{[1,2,3], null}"))
)
}
+
+ test("Test JSON data source maxStringLen option") {
+ // Create a JSON string that is way longer than DEFAULT_MAX_STRING_LEN.
+ val longStringSize = StreamReadConstraints.DEFAULT_MAX_STRING_LEN * 10
Review Comment:
If `* 10` works, `* 2` will - it's a test, not setting what the actual new max will be.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #51235:
URL: https://github.com/apache/spark/pull/51235#discussion_r2161071707
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -5016,6 +5016,14 @@ object SQLConf {
.booleanConf
.createWithDefault(false)
+ val JSON_MAX_STRING_LENGTH =
+ buildConf("spark.sql.json.defaultMaxStringLength")
+ .doc("Global default maximum string length limit when reading JSON data. It will be " +
+ "overridden if a JSONOption maxStringLen is provided.")
+ .version("3.5.0")
Review Comment:
This needs to be backported to 3.5 to fix a regression, how about `3.5.7`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "DapengShi (via GitHub)" <gi...@apache.org>.
DapengShi commented on PR #51235:
URL: https://github.com/apache/spark/pull/51235#issuecomment-3044134099
`GetJsonObject` is also affected by jackson 2.15 and it does not use `JSONOptions`, so can we fix all affected json related code in this PR? I think maybe we also need to improve `SharedFactory` in jsonExpressions.scala ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #51235:
URL: https://github.com/apache/spark/pull/51235#issuecomment-3420401270
I think this fix is no longer needed after https://github.com/apache/spark/pull/52049
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "ccage-simp (via GitHub)" <gi...@apache.org>.
ccage-simp commented on PR #51235:
URL: https://github.com/apache/spark/pull/51235#issuecomment-3413246171
Could this get picked up again? seeing this error constantly when trying to view spark history is a real hassle.
```
HTTP ERROR 500 com.fasterxml.jackson.core.exc.StreamConstraintsException: String length (20054016) exceeds the maximum length (20000000)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #51235:
URL: https://github.com/apache/spark/pull/51235#discussion_r2160631072
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -5016,6 +5016,14 @@ object SQLConf {
.booleanConf
.createWithDefault(false)
+ val JSON_MAX_STRING_LENGTH =
+ buildConf("spark.sql.json.defaultMaxStringLength")
+ .doc("Global default maximum string length limit when reading JSON data. It will be " +
+ "overridden if a JSONOption maxStringLen is provided.")
+ .version("3.5.0")
Review Comment:
4.1.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #51235:
URL: https://github.com/apache/spark/pull/51235#discussion_r2161073990
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JSONOptions.scala:
##########
@@ -55,7 +55,7 @@ class JSONOptions(
private val maxStringLen: Int = parameters
.get("maxStringLen")
.map(_.toInt)
- .getOrElse(StreamReadConstraints.DEFAULT_MAX_STRING_LEN)
+ .getOrElse(SQLConf.get.getConf(SQLConf.JSON_MAX_STRING_LENGTH))
Review Comment:
can we follow `ParquetOptions` and pass a `SQLConf` instance to construct `JSONOptions`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "tianhanhu (via GitHub)" <gi...@apache.org>.
tianhanhu commented on PR #51235:
URL: https://github.com/apache/spark/pull/51235#issuecomment-2992525548
cc @cloud-fan
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #51235:
URL: https://github.com/apache/spark/pull/51235#discussion_r2161074987
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala:
##########
@@ -4096,6 +4096,49 @@ abstract class JsonSuite
Row("{null, bad json}"), Row("{[1,2,3], null}"))
)
}
+
+ test("Test JSON data source maxStringLen option") {
+ // Create a JSON string that is way longer than DEFAULT_MAX_STRING_LEN.
+ val longStringSize = StreamReadConstraints.DEFAULT_MAX_STRING_LEN * 10
Review Comment:
does `* 2` work?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #51235: [SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf
URL: https://github.com/apache/spark/pull/51235
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org