swapna267 commented on code in PR #12191:
URL: https://github.com/apache/iceberg/pull/12191#discussion_r1947348896


##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/source/TestIcebergSourceSql.java:
##########
@@ -162,4 +173,74 @@ public void testWatermarkOptionsDescending() throws 
Exception {
         expected,
         SCHEMA_TS);
   }
+
+  @Test
+  public void testWatermarkInvalidConfig() {
+    CATALOG_EXTENSION.catalog().createTable(TestFixtures.TABLE_IDENTIFIER, 
SCHEMA_TS);
+
+    String flinkTable = "`default_catalog`.`default_database`.flink_table";
+    try {
+      SqlHelpers.sql(
+          getStreamingTableEnv(),
+          "CREATE TABLE %s "
+              + "(t1 TIMESTAMP(6), "
+              + "t2 BIGINT,"
+              + "eventTS AS CAST(t1 AS TIMESTAMP(3)), "
+              + "WATERMARK FOR eventTS AS SOURCE_WATERMARK()) WITH %s",
+          flinkTable,
+          SqlBase.toWithClause(getConnectorOptions()));
+
+      assertThatThrownBy(
+              () -> SqlHelpers.sql(getStreamingTableEnv(), "SELECT * FROM %s", 
flinkTable))
+          .isInstanceOf(NullPointerException.class)
+          .hasMessage("watermark-column needs to be configured to use source 
watermark.");
+    } finally {
+      SqlHelpers.sql(getStreamingTableEnv(), "DROP TABLE IF EXISTS %s", 
flinkTable);
+    }
+  }
+
+  @Test
+  public void testWatermarkValidConfig() throws Exception {
+    List<Record> expected = generateExpectedRecords(true);
+
+    Map<String, String> connectorOptions = 
Maps.newHashMap(getConnectorOptions());
+    connectorOptions.put("watermark-column", "t1");
+
+    String flinkTable = "`default_catalog`.`default_database`.flink_table";
+
+    SqlHelpers.sql(
+        getStreamingTableEnv(),
+        "CREATE TABLE %s "
+            + "(t1 TIMESTAMP(6), "
+            + "t2 BIGINT,"
+            + "eventTS AS CAST(t1 AS TIMESTAMP(3)), "
+            + "WATERMARK FOR eventTS AS SOURCE_WATERMARK()) WITH %s",
+        flinkTable,
+        SqlBase.toWithClause(connectorOptions));
+
+    TestHelpers.assertRecordsWithOrder(
+        SqlHelpers.sql(
+            getStreamingTableEnv(),
+            "SELECT t1, t2 FROM TABLE(TUMBLE(TABLE %s, DESCRIPTOR(eventTS), 
INTERVAL '1' SECOND))",
+            flinkTable),
+        expected,
+        SCHEMA_TS);
+  }
+
+  @NotNull
+  private static Map<String, String> getConnectorOptions() {

Review Comment:
   yes , that gives us an option to do create table LIKE and avoid connector 
properties.



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to