[SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf - #51235
[SPARK-52544][SQL] Allow configuring Json datasource string length limit through SQLConf#51235tianhanhu wants to merge 1 commit into
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.
This needs to be backported to 3.5 to fix a regression, how about 3.5.7?
| .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.
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.
If * 10 works, * 2 will - it's a test, not setting what the actual new max will be.
|
|
|
It looks like FasterXML have increased the size on their end (FasterXML/jackson-core#1014, FasterXML/jackson-core#1019) |
|
I think this fix is no longer needed after #52049 |
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.