This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch release-1.18
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.18 by this push:
     new f5c62abf747 [FLINK-28693][table] Janino compile failed because of the 
generated code refers a class in table-planner
f5c62abf747 is described below

commit f5c62abf7475ea8bc976de2a2079b1a9e29b79df
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Tue Apr 9 17:10:06 2024 +0200

    [FLINK-28693][table] Janino compile failed because of the generated code 
refers a class in table-planner
    
    Co-authored-by: Xuyang <[email protected]>
---
 .../CompileAndExecuteRemotePlanITCase.java         |   2 +-
 .../sql/{codegen => }/CreateTableAsITCase.java     |   2 +-
 .../table/sql/{codegen => }/HdfsITCaseBase.java    |   2 +-
 .../sql/{codegen => }/PlannerScalaFreeITCase.java  |  11 ++-
 .../table/sql/{codegen => }/SqlITCaseBase.java     |   2 +-
 .../sql/{codegen => }/UsingRemoteJarITCase.java    |   2 +-
 .../src/test/resources/watermark_push_down_e2e.sql |  44 +++++++++
 .../flink-sql-client-test/pom.xml                  |   7 ++
 .../TestScanTableSourceWithWatermarkPushDown.java  |  66 +++++++++++++
 ...canTableSourceWithWatermarkPushDownFactory.java |  52 ++++++++++
 .../flink/table/toolbox/TestSourceFunction.java    | 110 +++++++++++++++++++++
 .../org.apache.flink.table.factories.Factory       |  16 +++
 .../codegen/WatermarkGeneratorCodeGenerator.scala  |  10 +-
 ...neratorCodeGeneratorFunctionContextWrapper.java |  44 +++++++++
 14 files changed, 355 insertions(+), 15 deletions(-)

diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CompileAndExecuteRemotePlanITCase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CompileAndExecuteRemotePlanITCase.java
similarity index 98%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CompileAndExecuteRemotePlanITCase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CompileAndExecuteRemotePlanITCase.java
index b74c70794ab..439770cce24 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CompileAndExecuteRemotePlanITCase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CompileAndExecuteRemotePlanITCase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import org.apache.hadoop.fs.LocatedFileStatus;
 import org.apache.hadoop.fs.RemoteIterator;
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CreateTableAsITCase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CreateTableAsITCase.java
similarity index 98%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CreateTableAsITCase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CreateTableAsITCase.java
index fb727b73ee2..35a8ff605d1 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/CreateTableAsITCase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/CreateTableAsITCase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import 
org.apache.flink.formats.json.debezium.DebeziumJsonDeserializationSchema;
 import org.apache.flink.table.api.DataTypes;
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/HdfsITCaseBase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/HdfsITCaseBase.java
similarity index 99%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/HdfsITCaseBase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/HdfsITCaseBase.java
index a3f83ddd95a..4aa7601c03c 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/HdfsITCaseBase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/HdfsITCaseBase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import org.apache.flink.test.resources.ResourceTestUtils;
 import org.apache.flink.test.util.SQLJobSubmission;
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/PlannerScalaFreeITCase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/PlannerScalaFreeITCase.java
similarity index 88%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/PlannerScalaFreeITCase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/PlannerScalaFreeITCase.java
index 54db09be764..b6433e2c76a 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/PlannerScalaFreeITCase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/PlannerScalaFreeITCase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import 
org.apache.flink.formats.json.debezium.DebeziumJsonDeserializationSchema;
 import org.apache.flink.table.api.DataTypes;
@@ -33,6 +33,8 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import static org.junit.Assume.assumeTrue;
+
 /**
  * End-to-End tests for table planner scala-free since 1.15. Due to scala-free 
of table planner
  * introduced, the class in table planner is not visible in distribution 
runtime, if we use these
@@ -61,6 +63,13 @@ public class PlannerScalaFreeITCase extends SqlITCaseBase {
         runAndCheckSQL("scala_free_e2e.sql", Arrays.asList("+I[Bob, 2]", 
"+I[Alice, 1]"));
     }
 
+    /** The test data is from {@link 
org.apache.flink.table.toolbox.TestSourceFunction#DATA}. */
+    @Test
+    public void testWatermarkPushDown() throws Exception {
+        assumeTrue(executionMode.equalsIgnoreCase("streaming"));
+        runAndCheckSQL("watermark_push_down_e2e.sql", Arrays.asList("+I[Bob, 
1]", "+I[Alice, 2]"));
+    }
+
     @Override
     protected List<String> formatRawResult(List<String> rawResult) {
         return convertToMaterializedResult(rawResult, SINK_TABLE_SCHEMA, 
DESERIALIZATION_SCHEMA);
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/SqlITCaseBase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/SqlITCaseBase.java
similarity index 99%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/SqlITCaseBase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/SqlITCaseBase.java
index 5e66762dc84..2f448f6ec74 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/SqlITCaseBase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/SqlITCaseBase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import org.apache.flink.api.common.serialization.DeserializationSchema;
 import org.apache.flink.api.common.time.Deadline;
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/UsingRemoteJarITCase.java
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/UsingRemoteJarITCase.java
similarity index 99%
rename from 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/UsingRemoteJarITCase.java
rename to 
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/UsingRemoteJarITCase.java
index 45290971fa7..f1cceeaf2cf 100644
--- 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/UsingRemoteJarITCase.java
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/UsingRemoteJarITCase.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.sql.codegen;
+package org.apache.flink.table.sql;
 
 import 
org.apache.flink.formats.json.debezium.DebeziumJsonDeserializationSchema;
 import org.apache.flink.table.api.DataTypes;
diff --git 
a/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/resources/watermark_push_down_e2e.sql
 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/resources/watermark_push_down_e2e.sql
new file mode 100644
index 00000000000..ca3a4fe6472
--- /dev/null
+++ 
b/flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/resources/watermark_push_down_e2e.sql
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+CREATE TABLE SourceTable (
+    user_name STRING,
+    order_cnt BIGINT,
+    order_time TIMESTAMP(3),
+    ts AS COALESCE(`order_time` ,CURRENT_TIMESTAMP),
+    watermark FOR `ts` AS `ts` - INTERVAL '5' SECOND
+) WITH (
+    'connector' = 'test-scan-table-source-with-watermark-push-down'
+);
+
+CREATE TABLE SinkTable (
+    user_name STRING,
+    order_cnt BIGINT
+) WITH (
+    'connector' = 'filesystem',
+    'path' = '$RESULT',
+    'sink.rolling-policy.rollover-interval' = '2s',
+    'sink.rolling-policy.check-interval' = '2s',
+    'format' = 'debezium-json'
+);
+
+SET execution.runtime-mode = $MODE;
+
+INSERT INTO SinkTable
+SELECT user_name, order_cnt
+FROM SourceTable;
\ No newline at end of file
diff --git a/flink-end-to-end-tests/flink-sql-client-test/pom.xml 
b/flink-end-to-end-tests/flink-sql-client-test/pom.xml
index d7c1c1dc567..00c3d1f47a1 100644
--- a/flink-end-to-end-tests/flink-sql-client-test/pom.xml
+++ b/flink-end-to-end-tests/flink-sql-client-test/pom.xml
@@ -38,6 +38,13 @@ under the License.
                        <scope>provided</scope>
                </dependency>
 
+               <dependency>
+                       <groupId>org.apache.flink</groupId>
+                       <artifactId>flink-table-api-java-bridge</artifactId>
+                       <version>${project.version}</version>
+                       <scope>provided</scope>
+               </dependency>
+
                <dependency>
                        <groupId>org.apache.flink</groupId>
                        <artifactId>flink-end-to-end-tests-common</artifactId>
diff --git 
a/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDown.java
 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDown.java
new file mode 100644
index 00000000000..ab25aef2be6
--- /dev/null
+++ 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDown.java
@@ -0,0 +1,66 @@
+/*
+ * 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.flink.table.toolbox;
+
+import org.apache.flink.api.common.eventtime.WatermarkStrategy;
+import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import org.apache.flink.table.connector.source.ScanTableSource;
+import org.apache.flink.table.connector.source.SourceFunctionProvider;
+import 
org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown;
+import org.apache.flink.table.data.RowData;
+
+/**
+ * A source used to test {@link SupportsWatermarkPushDown}.
+ *
+ * <p>For simplicity, the deprecated source function method is used to create 
the source.
+ */
+public class TestScanTableSourceWithWatermarkPushDown
+        implements ScanTableSource, SupportsWatermarkPushDown {
+
+    private WatermarkStrategy<RowData> watermarkStrategy;
+
+    @Override
+    public void applyWatermark(WatermarkStrategy<RowData> watermarkStrategy) {
+        this.watermarkStrategy = watermarkStrategy;
+    }
+
+    @Override
+    public DynamicTableSource copy() {
+        final TestScanTableSourceWithWatermarkPushDown newSource =
+                new TestScanTableSourceWithWatermarkPushDown();
+        newSource.watermarkStrategy = this.watermarkStrategy;
+        return newSource;
+    }
+
+    @Override
+    public String asSummaryString() {
+        return "TestScanTableSourceWithWatermarkPushDown";
+    }
+
+    @Override
+    public ChangelogMode getChangelogMode() {
+        return ChangelogMode.insertOnly();
+    }
+
+    @Override
+    public ScanRuntimeProvider getScanRuntimeProvider(ScanContext 
runtimeProviderContext) {
+        return SourceFunctionProvider.of(new 
TestSourceFunction(watermarkStrategy), false);
+    }
+}
diff --git 
a/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDownFactory.java
 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDownFactory.java
new file mode 100644
index 00000000000..22452706c23
--- /dev/null
+++ 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestScanTableSourceWithWatermarkPushDownFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.table.toolbox;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import org.apache.flink.table.factories.DynamicTableSourceFactory;
+
+import java.util.Collections;
+import java.util.Set;
+
+/** A factory to create {@link TestScanTableSourceWithWatermarkPushDown}. */
+public class TestScanTableSourceWithWatermarkPushDownFactory implements 
DynamicTableSourceFactory {
+
+    public static final String IDENTIFIER = 
"test-scan-table-source-with-watermark-push-down";
+
+    @Override
+    public DynamicTableSource createDynamicTableSource(Context context) {
+        return new TestScanTableSourceWithWatermarkPushDown();
+    }
+
+    @Override
+    public String factoryIdentifier() {
+        return IDENTIFIER;
+    }
+
+    @Override
+    public Set<ConfigOption<?>> requiredOptions() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<ConfigOption<?>> optionalOptions() {
+        return Collections.emptySet();
+    }
+}
diff --git 
a/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestSourceFunction.java
 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestSourceFunction.java
new file mode 100644
index 00000000000..347db1589c8
--- /dev/null
+++ 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/java/org/apache/flink/table/toolbox/TestSourceFunction.java
@@ -0,0 +1,110 @@
+/*
+ * 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.flink.table.toolbox;
+
+import org.apache.flink.api.common.eventtime.Watermark;
+import org.apache.flink.api.common.eventtime.WatermarkGenerator;
+import org.apache.flink.api.common.eventtime.WatermarkOutput;
+import org.apache.flink.api.common.eventtime.WatermarkStrategy;
+import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A source function used to test.
+ *
+ * <p>For simplicity, the deprecated source function method is used to create 
the source.
+ */
+@SuppressWarnings("deprecation")
+public class TestSourceFunction implements SourceFunction<RowData> {
+
+    public static final List<List<Object>> DATA = new ArrayList<>();
+
+    static {
+        DATA.add(Arrays.asList(StringData.fromString("Bob"), 1L, 
TimestampData.fromEpochMillis(1)));
+        DATA.add(
+                Arrays.asList(
+                        StringData.fromString("Alice"), 2L, 
TimestampData.fromEpochMillis(2)));
+    }
+
+    private final WatermarkStrategy<RowData> watermarkStrategy;
+
+    public TestSourceFunction(WatermarkStrategy<RowData> watermarkStrategy) {
+        this.watermarkStrategy = watermarkStrategy;
+    }
+
+    private volatile boolean isRunning = true;
+
+    @Override
+    public void run(SourceContext<RowData> ctx) {
+        WatermarkGenerator<RowData> generator =
+                watermarkStrategy.createWatermarkGenerator(() -> null);
+        WatermarkOutput output = new TestWatermarkOutput(ctx);
+
+        int rowDataSize = DATA.get(0).size();
+        int index = 0;
+        while (index < DATA.size() && isRunning) {
+            List<Object> list = DATA.get(index);
+            GenericRowData row = new GenericRowData(rowDataSize);
+            for (int i = 0; i < rowDataSize; i++) {
+                row.setField(i, list.get(i));
+            }
+            generator.onEvent(row, Long.MIN_VALUE, output);
+            generator.onPeriodicEmit(output);
+
+            ctx.collect(row);
+
+            index++;
+        }
+        ctx.close();
+    }
+
+    @Override
+    public void cancel() {
+        isRunning = false;
+    }
+
+    private static class TestWatermarkOutput implements WatermarkOutput {
+
+        private final SourceFunction.SourceContext<RowData> ctx;
+
+        public TestWatermarkOutput(SourceFunction.SourceContext<RowData> ctx) {
+            this.ctx = ctx;
+        }
+
+        @Override
+        public void emitWatermark(Watermark watermark) {
+            ctx.emitWatermark(
+                    new org.apache.flink.streaming.api.watermark.Watermark(
+                            watermark.getTimestamp()));
+        }
+
+        @Override
+        public void markIdle() {}
+
+        @Override
+        public void markActive() {}
+    }
+}
diff --git 
a/flink-end-to-end-tests/flink-sql-client-test/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory
 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory
new file mode 100644
index 00000000000..97da349d71a
--- /dev/null
+++ 
b/flink-end-to-end-tests/flink-sql-client-test/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory
@@ -0,0 +1,16 @@
+# 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.
+
+org.apache.flink.table.toolbox.TestScanTableSourceWithWatermarkPushDownFactory
diff --git 
a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/WatermarkGeneratorCodeGenerator.scala
 
b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/WatermarkGeneratorCodeGenerator.scala
index ae6c437acc5..e3fb7402186 100644
--- 
a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/WatermarkGeneratorCodeGenerator.scala
+++ 
b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/WatermarkGeneratorCodeGenerator.scala
@@ -19,12 +19,11 @@ package org.apache.flink.table.planner.codegen
 
 import org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier
 import org.apache.flink.configuration.{Configuration, ReadableConfig}
-import org.apache.flink.metrics.MetricGroup
 import org.apache.flink.table.functions.{FunctionContext, UserDefinedFunction}
 import org.apache.flink.table.planner.calcite.FlinkTypeFactory
 import org.apache.flink.table.planner.codegen.CodeGenUtils.{newName, ROW_DATA}
 import org.apache.flink.table.planner.codegen.Indenter.toISC
-import org.apache.flink.table.runtime.generated.{GeneratedWatermarkGenerator, 
WatermarkGenerator}
+import org.apache.flink.table.runtime.generated.{GeneratedWatermarkGenerator, 
WatermarkGenerator, WatermarkGeneratorCodeGeneratorFunctionContextWrapper}
 import org.apache.flink.table.types.DataType
 import org.apache.flink.table.types.logical.{LogicalTypeRoot, RowType}
 
@@ -136,10 +135,3 @@ class WatermarkGeneratorFunctionContext(
     super.addReusableConverter(dataType, "this.getClass().getClassLoader()")
   }
 }
-
-class WatermarkGeneratorCodeGeneratorFunctionContextWrapper(
-    context: WatermarkGeneratorSupplier.Context)
-  extends FunctionContext(null, null, null) {
-
-  override def getMetricGroup: MetricGroup = context.getMetricGroup
-}
diff --git 
a/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/generated/WatermarkGeneratorCodeGeneratorFunctionContextWrapper.java
 
b/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/generated/WatermarkGeneratorCodeGeneratorFunctionContextWrapper.java
new file mode 100644
index 00000000000..633228291c7
--- /dev/null
+++ 
b/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/generated/WatermarkGeneratorCodeGeneratorFunctionContextWrapper.java
@@ -0,0 +1,44 @@
+/*
+ * 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.flink.table.runtime.generated;
+
+import org.apache.flink.api.common.eventtime.WatermarkGeneratorSupplier;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.table.functions.FunctionContext;
+
+/**
+ * A function wrapper for {@link FunctionContext} if the source supports {@link
+ * 
org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown}.
+ *
+ * <p>See more in {@link WatermarkGeneratorFunctionContext}.
+ */
+public class WatermarkGeneratorCodeGeneratorFunctionContextWrapper extends 
FunctionContext {
+    private final WatermarkGeneratorSupplier.Context context;
+
+    public WatermarkGeneratorCodeGeneratorFunctionContextWrapper(
+            WatermarkGeneratorSupplier.Context context) {
+        super(null, null, null);
+        this.context = context;
+    }
+
+    @Override
+    public MetricGroup getMetricGroup() {
+        return context.getMetricGroup();
+    }
+}

Reply via email to