Yaohua628 commented on code in PR #39996:
URL: https://github.com/apache/spark/pull/39996#discussion_r1105947864
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileMetadataStructSuite.scala:
##########
@@ -799,4 +828,36 @@ class FileMetadataStructSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("SPARK-42423: Add metadata column file block start and length") {
+ withSQLConf(
+ SQLConf.LEAF_NODE_DEFAULT_PARALLELISM.key -> "1",
+ SQLConf.FILES_MAX_PARTITION_BYTES.key -> "1") {
+ withTempPath { path =>
+ spark.range(2).write.json(path.getCanonicalPath)
+ assert(path.listFiles().count(_.getName.endsWith("json")) == 1)
+
+ val df = spark.read.json(path.getCanonicalPath)
+ .select("id", METADATA_FILE_BLOCK_START, METADATA_FILE_BLOCK_LENGTH)
+ assert(df.rdd.partitions.length > 1)
+ val res = df.collect()
+ assert(res.length == 2)
+ assert(res.head.getLong(0) == 0)
+ assert(res.head.getLong(1) == 0)
+ assert(res.head.getLong(2) > 0)
+ assert(res(1).getLong(0) == 1L)
+ assert(res(1).getLong(1) > 0)
+ assert(res(1).getLong(2) > 0)
+
+ val df2 = spark.read.json(path.getCanonicalPath)
+ .where("_metadata.File_bLoCk_start > 0 and _metadata.file_SizE > 0")
+ .select("id", METADATA_FILE_BLOCK_START, METADATA_FILE_BLOCK_LENGTH)
+ val res2 = df2.collect()
+ assert(res2.length == 1)
+ assert(res2.head.getLong(0) == 1L)
+ assert(res2.head.getLong(1) > 0)
+ assert(res2.head.getLong(2) > 0)
Review Comment:
Super nit: could you add in-line comments (each row, each column, each
value) for better readability? Thanks!
--
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]