voonhous commented on code in PR #19406:
URL: https://github.com/apache/hudi/pull/19406#discussion_r3690591886


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestNestedSchemaPruningOptimization.scala:
##########
@@ -167,6 +148,128 @@ class TestNestedSchemaPruningOptimization extends 
HoodieSparkSqlTestBase with Sp
     }
   }
 
+  test("Test NestedSchemaPruning prunes nested struct when array and map 
columns are present") {
+    withTempDir { tmp =>
+      val tableName = generateTableName
+      val tablePath = s"${tmp.getCanonicalPath}/$tableName"
+
+      createTableWithComplexNestedSchema(tableName, tablePath)
+
+      // Only a single nested sub-field is projected, so "item" is pruned down 
to just "name" and the
+      // unreferenced "tags" (array<struct>) and "props" (map<string,struct>) 
columns are dropped.
+      // Traversing the full data schema exercises the array and map branches 
of countLeaves.

Review Comment:
   Filed #19447.



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestNestedSchemaPruningOptimization.scala:
##########
@@ -167,6 +148,128 @@ class TestNestedSchemaPruningOptimization extends 
HoodieSparkSqlTestBase with Sp
     }
   }
 
+  test("Test NestedSchemaPruning prunes nested struct when array and map 
columns are present") {
+    withTempDir { tmp =>
+      val tableName = generateTableName
+      val tablePath = s"${tmp.getCanonicalPath}/$tableName"
+
+      createTableWithComplexNestedSchema(tableName, tablePath)
+
+      // Only a single nested sub-field is projected, so "item" is pruned down 
to just "name" and the
+      // unreferenced "tags" (array<struct>) and "props" (map<string,struct>) 
columns are dropped.
+      // Traversing the full data schema exercises the array and map branches 
of countLeaves.
+      val selectDF = spark.sql(s"SELECT id, item.name FROM $tableName")
+
+      val expectedSchema = StructType(Seq(
+        StructField("id", IntegerType, nullable = true),
+        StructField("item", StructType(Seq(StructField("name", StringType, 
nullable = false))), nullable = true)
+      ))
+      val expectedReadSchemaClause = "ReadSchema: 
struct<id:int,item:struct<name:string>>"
+
+      assertPrunedReadSchema(selectDF, tableName, expectedSchema, 
expectedReadSchemaClause)
+
+      // Execute the query to make sure it's working as expected (smoke test)
+      selectDF.count

Review Comment:
   Filed #19448.



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

Reply via email to