dejankrak-db commented on code in PR #59305:
URL: https://github.com/apache/spark/pull/59305#discussion_r4277507788
##########
sql/api/src/main/scala/org/apache/spark/sql/types/DataType.scala:
##########
@@ -344,6 +345,16 @@ object DataType {
TimestampNTZNanosType(p)
}
case "timestamp_ltz" => TimestampType
+ case FILE_TYPE(mode) =>
+ // Bare `"file"` resolves differently depending on context: inside a
StructField it is
+ // an external file, which is also what a schema written without any
metadata means; in a
+ // standalone parse (top-level `fromJson` or recursion outside any
StructField) it has no
+ // mode yet, as when a UDF's return type is serialized as a bare
`"file"`.
Review Comment:
Agreed, a nested file in a UDF type should stay unknown. Fixed in
f30470017b8 (together with 9c76b11358a): the JSON form of a FileType carries
its mode, as `"file external"` or `"file unknown"`, so a nested unknown file
round-trips in a struct field, an array, a map and standalone. An external file
in a struct field is the plain `"file"`, so a schema written by another engine
is written back with the same type. `inStructField` stays for reading a bare
`"file"`: external inside a struct field and unknown elsewhere. Any other mode
name is rejected with `INVALID_JSON_DATA_TYPE`. `DataTypeSuite` has tests for a
nested unknown file in a struct, an array and a nested struct, and for a bare
`"file"` nested in an array and a map.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]