HyukjinKwon commented on code in PR #59305:
URL: https://github.com/apache/spark/pull/59305#discussion_r4266609435


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala:
##########
@@ -1708,6 +1708,71 @@ class DataTypeSuite extends SparkFunSuite with SQLHelper 
{
     }
   }
 
+  test("FileType: name, JSON and DDL round trip") {
+    // The mode is part of the type's identity.
+    assert(FileType.external != FileType())
+    assert(FileType() === FileType(FileTypeMode.UNKNOWN))
+    assert(DataTypes.FileType === FileType())
+    assert(FileType.external.typeName === "file external")
+    assert(FileType().typeName === "file")
+    // A type prints what was written: FILE EXTERNAL for an external file, 
FILE for a bare FILE.
+    assert(FileType.external.sql === "FILE EXTERNAL")
+    assert(FileType().sql === "FILE")
+    assert(FileType.external.json === "\"file external\"")
+    assert(FileType().json === "\"file\"")
+    assert(DataType.fromJson("\"file external\"") === FileType.external)
+    // A bare "file" has no mode on its own, and is an external file inside a 
struct field.
+    assert(DataType.fromJson("\"file\"") === FileType())

Review Comment:
   Thanks, verified. The new `DataTypeSuite` test covers all three branches 
with exact assertions: standalone array and map elements keep the unknown mode, 
the field shapes without `metadata` or `nullable` read as external, and a 
nested FILE schema decodes with the flag off.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4254684297","thread_id":"inline:4254684297","verdict_sha256":"fe20246ec1d53acf9c1fbd2c1cd0c9bf38bfb18bbed290ee0f9b9b4facc6784a"}
 -->



-- 
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]

Reply via email to