rahil-c commented on code in PR #14355:
URL: https://github.com/apache/hudi/pull/14355#discussion_r2582769591


##########
hudi-client/hudi-flink-client/src/test/java/org/apache/hudi/util/TestHoodieSchemaConverter.java:
##########
@@ -0,0 +1,432 @@
+/*
+ * 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.util;
+
+import org.apache.hudi.common.schema.HoodieSchema;
+import org.apache.hudi.common.schema.HoodieSchemaType;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.ArrayType;
+import org.apache.flink.table.types.logical.DecimalType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.MapType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.types.logical.TimestampType;
+import org.apache.flink.table.types.logical.VarCharType;
+import org.apache.flink.table.types.logical.VarBinaryType;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Tests for {@link HoodieSchemaConverter}.
+ */
+public class TestHoodieSchemaConverter {
+
+  @Test
+  public void testPrimitiveTypes() {
+    // String
+    HoodieSchema stringSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.STRING().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.STRING, stringSchema.getType());
+
+    // Int
+    HoodieSchema intSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.INT().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.INT, intSchema.getType());
+
+    // Long
+    HoodieSchema longSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.BIGINT().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.LONG, longSchema.getType());
+
+    // Float
+    HoodieSchema floatSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.FLOAT().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.FLOAT, floatSchema.getType());
+
+    // Double
+    HoodieSchema doubleSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.DOUBLE().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.DOUBLE, doubleSchema.getType());
+
+    // Boolean
+    HoodieSchema boolSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.BOOLEAN().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.BOOLEAN, boolSchema.getType());
+
+    // Bytes
+    HoodieSchema bytesSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.BYTES().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.BYTES, bytesSchema.getType());
+  }
+
+  @Test
+  public void testNullableTypes() {
+    HoodieSchema nullableString = HoodieSchemaConverter.convertToSchema(
+        DataTypes.STRING().nullable().getLogicalType());
+    assertEquals(HoodieSchemaType.UNION, nullableString.getType());
+    assertTrue(nullableString.isNullable());
+
+    HoodieSchema nullableInt = HoodieSchemaConverter.convertToSchema(
+        DataTypes.INT().nullable().getLogicalType());
+    assertEquals(HoodieSchemaType.UNION, nullableInt.getType());
+    assertTrue(nullableInt.isNullable());
+  }
+
+  @Test
+  public void testTemporalTypes() {
+    // Date
+    HoodieSchema dateSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.DATE().notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.DATE, dateSchema.getType());
+
+    // Time
+    HoodieSchema timeSchema = HoodieSchemaConverter.convertToSchema(
+        DataTypes.TIME(3).notNull().getLogicalType());
+    assertEquals(HoodieSchemaType.TIME, timeSchema.getType());

Review Comment:
   Will make this change.
   
   Just one thing to callout here in case someone from hudi flink review this 
as well. I noticed that the `AvroSchemaConverter` in the hudi flink module says 
it does not support micros for 
`Time`.https://github.com/apache/hudi/blob/master/hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/util/AvroSchemaConverter.java#L291
 
   
   However when checking the avro spec I think time technically time is 
supported with micros
   
https://avro.apache.org/docs/1.8.0/spec.html#Time+%28microsecond+precision%29, 
so will add this functionaltiy in the `HoodieSchemaConverter` class



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