MaxGekk commented on a change in pull request #27774: [SPARK-31023][SQL]
Support foldable schemas by `from_json`
URL: https://github.com/apache/spark/pull/27774#discussion_r387459222
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/JsonFunctionsSuite.scala
##########
@@ -653,4 +653,18 @@ class JsonFunctionsSuite extends QueryTest with
SharedSparkSession {
assert(json_tuple_result === len)
}
}
+
+ test("support foldable schema by from_json") {
+ val options = Map[String, String]().asJava
+ val schema = regexp_replace(lit("dpt_org_id INT, dpt_org_city STRING"),
"dpt_org_", "")
Review comment:
> I couldn't come up with the case where the foldable expression is used.
For example, you import data from another db by dumping the data to csv
files. You take the schema from the dbms, and find out difference in types -
the dbms uses VARCHAR(100) for strings. By using replace, you could replace it
by STRING. Or text format of schema could be different, so, using Spark's
string functions you could correct it. If you cannot edit it on-the-fly, you
have to hardcoded schema in your app, and take care of sync.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]