the-other-tim-brown commented on code in PR #17904: URL: https://github.com/apache/hudi/pull/17904#discussion_r2765249358
########## hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/execution/datasources/SparkSchemaTransformUtils.scala: ########## @@ -0,0 +1,426 @@ +/* + * 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.HoodieSchemaUtils +import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection +import org.apache.spark.sql.catalyst.expressions.{ArrayTransform, Attribute, AttributeReference, Cast, CreateNamedStruct, CreateStruct, Expression, GetStructField, LambdaFunction, Literal, MapEntries, MapFromEntries, NamedLambdaVariable, UnsafeProjection} +import org.apache.spark.sql.types.{ArrayType, DataType, DateType, DecimalType, DoubleType, FloatType, IntegerType, LongType, MapType, StringType, StructField, StructType, TimestampNTZType} + +/** + * Format-agnostic utilities for Spark schema transformations including NULL padding + * and recursive type casting with workarounds for unsafe conversions. + * + * These utilities are used by file format readers that need to: + * - Pad missing columns with NULL literals (required for Lance) + * - Handle nested struct/array/map type conversions + * - Work around Spark unsafe cast issues (float->double, numeric->decimal) + * + * Note: The following functions were originally part of HoodieParquetFileFormatHelper + * and have been moved here to allow reuse across multiple file formats: + * - buildImplicitSchemaChangeInfo + * - isDataTypeEqual + * - generateUnsafeProjection + * - hasUnsupportedConversion + * - recursivelyCastExpressions Review Comment: I don't think we need this in the code itself. It can be a comment on this PR for any future developers that are trying to step through changes to the repo. -- 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]
