beryllw commented on code in PR #3420:
URL: https://github.com/apache/fluss/pull/3420#discussion_r3541073576


##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/tiering/source/watermark/SimpleWatermarkExtractorTest.java:
##########
@@ -0,0 +1,371 @@
+/*
+ * 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.fluss.flink.tiering.source.watermark;
+
+import org.apache.fluss.config.Configuration;
+import org.apache.fluss.lake.batch.ArrowRecordBatch;
+import org.apache.fluss.metadata.Schema;
+import org.apache.fluss.metadata.TableInfo;
+import org.apache.fluss.metadata.TablePath;
+import org.apache.fluss.record.ArrowBatchData;
+import org.apache.fluss.row.GenericRow;
+import org.apache.fluss.row.TimestampLtz;
+import org.apache.fluss.row.TimestampNtz;
+import org.apache.fluss.types.DataTypes;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.TimeStampMilliVector;
+import org.apache.arrow.vector.VectorSchemaRoot;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link SimpleWatermarkExtractor}. */
+class SimpleWatermarkExtractorTest {
+
+    @Test
+    void testCreateWithNoWatermarkConfig() {
+        TableInfo tableInfo = createTableInfoWithoutWatermark();
+        assertThat(SimpleWatermarkExtractor.create(tableInfo)).isNull();
+    }
+
+    @Test
+    void testCreateWithSimpleColumn() {
+        TableInfo tableInfo = createTableInfoWithWatermark("`ts`", 
"TIMESTAMP(3)");
+        SimpleWatermarkExtractor extractor = 
SimpleWatermarkExtractor.create(tableInfo);
+        assertThat(extractor).isNotNull();
+
+        GenericRow row = GenericRow.of(1, TimestampNtz.fromMillis(1000L));
+        assertThat(extractor.currentWatermark(row)).isEqualTo(1000L);
+    }
+
+    @Test
+    void testCreateWithSimpleColumnWithoutBackticks() {
+        TableInfo tableInfo = createTableInfoWithWatermark("ts", 
"TIMESTAMP(3)");
+        SimpleWatermarkExtractor extractor = 
SimpleWatermarkExtractor.create(tableInfo);
+        assertThat(extractor).isNotNull();
+
+        GenericRow row = GenericRow.of(1, TimestampNtz.fromMillis(2000L));
+        assertThat(extractor.currentWatermark(row)).isEqualTo(2000L);
+    }
+
+    @Test
+    void testCreateWithColumnMinusInterval() {

Review Comment:
   Nice and thorough coverage here 👍. Just a small non-blocking suggestion: 
testCreateWithColumnMinusInterval / Decimal / Minute / Hour / Day share the 
exact same structure and differ only in the expression and expected value. 
Following the existing testCreateWithTimestampPrecision in this file, they 
could be folded into a single @ParameterizedTest with @CsvSource — that way 
adding new cases (e.g. lowercase units or non-backtick columns) is just one 
more row, and the intent reads more clearly. The Arrow-batch tests are fine to 
keep separate given the variable rows/nulls. 
   
   ```
   @ParameterizedTest
   @CsvSource({
       // expr, inputMillis, expectedWatermarkMillis
       "`ts`,                           1000,      1000",
       "ts,                             2000,      2000",
       "`ts` - INTERVAL '5' SECOND,     10000,     5000",
       "`ts` - INTERVAL '0.001' SECOND, 1000,      999",
       "`ts` - INTERVAL '2' MINUTE,     200000,    80000",
       "`ts` - INTERVAL '1' HOUR,       7200000,   3600000",
       "`ts` - INTERVAL '1' DAY,        172800000, 86400000",
   })
   void testNtzWatermarkExtraction(String expr, long inputMillis, long 
expectedMillis) {
   ```



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