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


##########
hudi-spark-datasource/hudi-spark-common/src/test/scala/org/apache/hudi/schema/TestHoodieSparkSchemaUtils.scala:
##########
@@ -55,6 +56,177 @@ class TestHoodieSparkSchemaUtils {
     assertFieldType(schema, "nested_field.nested_string", StringType)
   }
 
+  @Test
+  def testGetNestedFieldWithArraySpark(): Unit = {

Review Comment:
   We can parameterize the tests here, instead of writing so many tests, we can 
make it more maintainable like this:
   
   ```scala
   @ParameterizedTest
   @CsvSource(value = Array(
     "items.array,             items.list.element,       string", // Input 
Spark -> Expect Avro Key
     "items.list.element,      items.list.element,       string", // Input Avro 
 -> Expect Avro Key
     "items.array.nested,      items.list.element.nested, int",   // Nested 
Spark
     "items.list.element.nested, items.list.element.nested, int"  // Nested Avro
   ))
   def testPathNormalization(inputPath: String, expectedKey: String, 
expectedType: String): Unit = {
     val result = HoodieSchemaUtils.getSchemaForField(complexSchema, inputPath)
     assertEquals(expectedKey, result.getKey) // Verifies normalization
     assertEquals(expectedType, result.getValue.dataType.simpleString)
   }
   ```



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