pvary commented on code in PR #14245:
URL: https://github.com/apache/iceberg/pull/14245#discussion_r2414560555


##########
flink/v2.1/flink/src/test/java/org/apache/iceberg/flink/source/reader/TestColumnStatsWatermarkExtractorEndToEnd.java:
##########
@@ -0,0 +1,233 @@
+/*
+ * 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.iceberg.flink.source.reader;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.types.Row;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.Parameter;
+import org.apache.iceberg.ParameterizedTestExtension;
+import org.apache.iceberg.Parameters;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.data.GenericAppenderHelper;
+import org.apache.iceberg.data.RandomGenericData;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.flink.FlinkSchemaUtil;
+import org.apache.iceberg.flink.HadoopTableExtension;
+import org.apache.iceberg.flink.TestHelpers;
+import org.apache.iceberg.flink.source.FlinkInputFormat;
+import org.apache.iceberg.flink.source.FlinkSource;
+import org.apache.iceberg.types.Types;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * End-to-end tests for ColumnStatsWatermarkExtractor with nanosecond 
precision timestamps. This
+ * test validates that watermark extraction works correctly with actual data 
files containing
+ * nanosecond precision timestamps.
+ */
+@ExtendWith(ParameterizedTestExtension.class)
+public class TestColumnStatsWatermarkExtractorEndToEnd {
+
+  @Parameter(index = 0)
+  private FileFormat format;
+
+  @Parameters(name = "format = {0}")
+  public static Object[][] parameters() {
+    return new Object[][] {{FileFormat.PARQUET}, {FileFormat.AVRO}};
+  }
+
+  private static final String DATABASE = "test_db";
+  private static final String TABLE = "test_watermark_table";
+
+  // Schema with nanosecond precision timestamps for watermark testing
+  // Contains both nanosecond (ns) and microsecond (micros) precision 
timestamps
+  private static final Schema NANOSECOND_WATERMARK_SCHEMA =
+      new Schema(
+          required(1, "id", Types.LongType.get()),
+          required(2, "event_time_ns", Types.TimestampNanoType.withoutZone()),
+          required(3, "event_time_ns_tz", Types.TimestampNanoType.withZone()),
+          required(4, "event_time_micros", Types.TimestampType.withoutZone()),
+          required(5, "data", Types.StringType.get()));
+
+  @TempDir protected Path temporaryDirectory;
+
+  @RegisterExtension
+  private static final HadoopTableExtension TABLE_EXTENSION =
+      HadoopTableExtension.withFormatVersion3(DATABASE, TABLE, 
NANOSECOND_WATERMARK_SCHEMA);
+
+  /**
+   * Tests that ColumnStatsWatermarkExtractor can be instantiated with both 
nanosecond and
+   * microsecond precision timestamp columns. This verifies that the extractor 
correctly recognizes
+   * and accepts both TIMESTAMP_NANO and TIMESTAMP column types.
+   */
+  @Test
+  public void testWatermarkExtractorCreationWithNanosecondTimestamps() {
+    Table table = TABLE_EXTENSION.table();
+
+    // Test that we can create watermark extractors for nanosecond timestamp 
columns
+    ColumnStatsWatermarkExtractor extractorNs =
+        new ColumnStatsWatermarkExtractor(table.schema(), "event_time_ns", 
TimeUnit.MICROSECONDS);
+    assertThat(extractorNs).isNotNull();
+
+    ColumnStatsWatermarkExtractor extractorNsTz =
+        new ColumnStatsWatermarkExtractor(
+            table.schema(), "event_time_ns_tz", TimeUnit.MICROSECONDS);
+    assertThat(extractorNsTz).isNotNull();
+
+    // Test that we can still create extractors for microsecond timestamp 
columns
+    ColumnStatsWatermarkExtractor extractorMicros =
+        new ColumnStatsWatermarkExtractor(
+            table.schema(), "event_time_micros", TimeUnit.MICROSECONDS);
+    assertThat(extractorMicros).isNotNull();

Review Comment:
   This could not be null.
   Are you trying to test if the previous line did not throw an error? Then use 
`assertDoesNotThrow`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to