danny0405 commented on code in PR #8449:
URL: https://github.com/apache/hudi/pull/8449#discussion_r1168301754


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/util/TestExpressionUtils.java:
##########
@@ -0,0 +1,166 @@
+/*
+ * 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.flink.table.api.DataTypes;
+import org.apache.flink.table.expressions.CallExpression;
+import org.apache.flink.table.expressions.Expression;
+import org.apache.flink.table.expressions.FieldReferenceExpression;
+import org.apache.flink.table.expressions.ValueLiteralExpression;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.types.AtomicDataType;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.BigIntType;
+import org.apache.flink.table.types.logical.BooleanType;
+import org.apache.flink.table.types.logical.DateType;
+import org.apache.flink.table.types.logical.DecimalType;
+import org.apache.flink.table.types.logical.DoubleType;
+import org.apache.flink.table.types.logical.FloatType;
+import org.apache.flink.table.types.logical.IntType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.table.types.logical.SmallIntType;
+import org.apache.flink.table.types.logical.TimeType;
+import org.apache.flink.table.types.logical.TimestampType;
+import org.apache.flink.table.types.logical.TinyIntType;
+import org.apache.flink.table.types.logical.VarBinaryType;
+import org.apache.flink.table.types.logical.VarCharType;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoField;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class TestExpressionUtils {
+
+  private static final DataType ROW_DATA_TYPE = DataTypes.ROW(
+      DataTypes.FIELD("f_tinyint", DataTypes.TINYINT()),
+      DataTypes.FIELD("f_smallint", DataTypes.SMALLINT()),
+      DataTypes.FIELD("f_int", DataTypes.INT()),
+      DataTypes.FIELD("f_long", DataTypes.BIGINT()),
+      DataTypes.FIELD("f_float", DataTypes.FLOAT()),
+      DataTypes.FIELD("f_double", DataTypes.DOUBLE()),
+      DataTypes.FIELD("f_boolean", DataTypes.BOOLEAN()),
+      DataTypes.FIELD("f_decimal", DataTypes.DECIMAL(10, 2)),
+      DataTypes.FIELD("f_bytes", DataTypes.VARBINARY(10)),
+      DataTypes.FIELD("f_string", DataTypes.VARCHAR(10)),
+      DataTypes.FIELD("f_time", DataTypes.TIME(3)),
+      DataTypes.FIELD("f_date", DataTypes.DATE()),
+      DataTypes.FIELD("f_timestamp", DataTypes.TIMESTAMP(3))
+  ).notNull();
+
+
+  private static final DataType ROW_DATA_TYPE_FIELD_NON_NULL = DataTypes.ROW(
+      DataTypes.FIELD("f_tinyint", new AtomicDataType(new TinyIntType(false))),

Review Comment:
   just use the `ROW_DATA_TYPE` for testing non null values, the nullability 
does not affect the testing results.



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/ExpressionUtils.java:
##########
@@ -150,23 +150,27 @@ public static Object 
getValueFromLiteral(ValueLiteralExpression expr) {
     switch (logicalType.getTypeRoot()) {
       case TIMESTAMP_WITHOUT_TIME_ZONE:
         return expr.getValueAs(LocalDateTime.class)
-            .map(ldt -> ldt.toInstant(ZoneOffset.UTC).toEpochMilli())
-            .orElse(null);
+                   .map(ldt -> ldt.toInstant(ZoneOffset.UTC).toEpochMilli())
+                   .orElse(null);
       case TIME_WITHOUT_TIME_ZONE:
         return expr.getValueAs(LocalTime.class)
-            .map(lt -> lt.get(ChronoField.MILLI_OF_DAY))
-            .orElse(null);
+                   .map(lt -> lt.get(ChronoField.MILLI_OF_DAY))
+                   .orElse(null);

Review Comment:
   Fix all the unnecessary changes for indentation.



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to