You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "hvanhovell (via GitHub)" <gi...@apache.org> on 2024/08/01 21:12:08 UTC
[PR] [SPARK-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
hvanhovell opened a new pull request, #47573:
URL: https://github.com/apache/spark/pull/47573
### What changes were proposed in this pull request?
We allow the `JsonToStructs` and `XmlToStructs` expressions to use a json schema.
### Why are the changes needed?
A couple of reasons:
- We want to use a reference to the `from_json` and `from_xml` methods in the Column API in order to make unification of the Classic and Connect Scala clients possible.
- Reduce the amount of duplication between the Function API and the SparkConnectPlanner.
- Make DataFrame and SQL API behave the same.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Existing tests.
### Was this patch authored or co-authored using generative AI tooling?
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "hvanhovell (via GitHub)" <gi...@apache.org>.
hvanhovell commented on code in PR #47573:
URL: https://github.com/apache/spark/pull/47573#discussion_r1704570893
##########
sql/core/src/test/scala/org/apache/spark/sql/JsonFunctionsSuite.scala:
##########
@@ -1204,42 +1204,32 @@ class JsonFunctionsSuite extends QueryTest with SharedSparkSession {
val df = Seq("""{"a":1}""").toDF("json")
val invalidJsonSchema = """{"fields": [{"a":123}], "type": "struct"}"""
checkError(
- exception = intercept[SparkIllegalArgumentException] {
+ exception = intercept[AnalysisException] {
Review Comment:
Another option would be that we pass a schema format using options.
--
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #47573:
URL: https://github.com/apache/spark/pull/47573#issuecomment-2270213907
Merged to master.
--
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "hvanhovell (via GitHub)" <gi...@apache.org>.
hvanhovell commented on PR #47573:
URL: https://github.com/apache/spark/pull/47573#issuecomment-2269030845
@dongjoon-hyun yeah, working on it.
--
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "hvanhovell (via GitHub)" <gi...@apache.org>.
hvanhovell commented on code in PR #47573:
URL: https://github.com/apache/spark/pull/47573#discussion_r1704565599
##########
sql/core/src/test/scala/org/apache/spark/sql/JsonFunctionsSuite.scala:
##########
@@ -1204,42 +1204,32 @@ class JsonFunctionsSuite extends QueryTest with SharedSparkSession {
val df = Seq("""{"a":1}""").toDF("json")
val invalidJsonSchema = """{"fields": [{"a":123}], "type": "struct"}"""
checkError(
- exception = intercept[SparkIllegalArgumentException] {
+ exception = intercept[AnalysisException] {
Review Comment:
These changes are a result of the parsing order. The only thing we can do to make this better is to homogenise schema parsing errors.
--
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #47573: [SPARK-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas
URL: https://github.com/apache/spark/pull/47573
--
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-49083][CONNECT] Allow from_xml and from_json to natively work with json schemas [spark]
Posted by "hvanhovell (via GitHub)" <gi...@apache.org>.
hvanhovell commented on PR #47573:
URL: https://github.com/apache/spark/pull/47573#issuecomment-2264002959
@HyukjinKwon should this go in the migration guide?
--
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