-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf #51235
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
base: master
Are you sure you want to change the base?
Conversation
cc @cloud-fan |
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.1.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be backported to 3.5 to fix a regression, how about 3.5.7
?
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we follow ParquetOptions
and pass a SQLConf
instance to construct JSONOptions
?
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does * 2
work?
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?
Yes, added a new user configurable config for specifying max string length for Json connector.
How was this patch tested?
New unit tests.
Was this patch authored or co-authored using generative AI tooling?
No.