codope commented on code in PR #12623:
URL: https://github.com/apache/hudi/pull/12623#discussion_r1919801640


##########
hudi-spark-datasource/hudi-spark-common/src/main/java/org/apache/hudi/schema/HoodieSparkSchemaUtils.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.hudi.schema;
+
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.common.util.VisibleForTesting;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.exception.HoodieException;
+
+import org.apache.spark.sql.types.StructField;
+import org.apache.spark.sql.types.StructType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HoodieSparkSchemaUtils {

Review Comment:
   In my comment, I did not mean to create a new util class. Just need to move 
these methods here - 
https://github.com/apache/hudi/blob/master/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSchemaUtils.scala



##########
hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java:
##########
@@ -1551,4 +1552,30 @@ private static Pair<Boolean, String> 
getIsValueWrapperObfuscated(GenericRecord r
     }
     return Pair.of(false, null);
   }
+
+  /**
+   * Returns field name and the resp data type of the field. The data type 
will always refer to the leaf node.
+   * for eg, for a.b.c, we turn Pair.of(a.b.c, DataType(c))
+   * @param schema schema of table.
+   * @param fieldName field name of interest.
+   * @return
+   */
+  @VisibleForTesting
+  public static Pair<String, Schema.Field> getSchemaForField(Schema schema, 
String fieldName) {
+    return getSchemaForField(schema, fieldName, StringUtils.EMPTY_STRING);
+  }
+
+  @VisibleForTesting
+  public static Pair<String, Schema.Field> getSchemaForField(Schema schema, 
String fieldName, String prefix) {

Review Comment:
   Can we please add direct UTs for the methods with simple field, nested 
field, nullable/non-nullable? I know it's already being tested for nested 
fields in TestColumnStatsIndex. But, it would be better to cover all cases 
including edge cases in a separate UT for this methd itself.



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