rahil-c commented on code in PR #17904: URL: https://github.com/apache/hudi/pull/17904#discussion_r2766705724
########## hudi-client/hudi-spark-client/src/test/scala/org/apache/spark/sql/execution/datasources/TestSparkSchemaTransformUtils.scala: ########## @@ -0,0 +1,288 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.execution.datasources + +import org.apache.spark.sql.catalyst.expressions.GenericInternalRow +import org.apache.spark.sql.catalyst.util.ArrayData +import org.apache.spark.sql.types._ +import org.apache.spark.unsafe.types.UTF8String +import org.junit.jupiter.api.Assertions.{assertEquals, assertTrue} +import org.junit.jupiter.api.Test + +class TestSparkSchemaTransformUtils { Review Comment: added a map test, for the struct test did you mean something like this where the entire struct is coming in as null in input? ``` @Test def testGenerateNullPaddingProjection_nullStructInInputRow(): Unit = { // Input schema: person: struct<name: string> val inputSchema = StructType(Seq( StructField("person", StructType(Seq( StructField("name", StringType, nullable = false) )), nullable = true) )) // Target schema: person: struct<name: string, age: int, city: string> val targetSchema = StructType(Seq( StructField("person", StructType(Seq( StructField("name", StringType, nullable = false), StructField("age", IntegerType, nullable = true), StructField("city", StringType, nullable = true) )), nullable = true) )) val projection = SparkSchemaTransformUtils.generateNullPaddingProjection(inputSchema, targetSchema) // Test with sample data where person struct is NULL val inputRow = new GenericInternalRow(Array[Any](null)) val outputRow = projection.apply(inputRow) // Verify the struct remains NULL assertEquals(1, outputRow.numFields) assertTrue(outputRow.isNullAt(0), "person field should remain NULL") } ``` -- 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]
