fapaul commented on a change in pull request #17759:
URL: https://github.com/apache/flink/pull/17759#discussion_r748158458



##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/DataStreamJavaITCase.java
##########
@@ -47,19 +49,29 @@
 import org.apache.flink.table.catalog.ResolvedSchema;
 import org.apache.flink.table.catalog.WatermarkSpec;
 import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.sink.DataStreamSinkProvider;
+import org.apache.flink.table.connector.sink.SinkProvider;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import org.apache.flink.table.connector.source.SourceFunctionProvider;
+import org.apache.flink.table.data.RowData;
 import org.apache.flink.table.expressions.utils.ResolvedExpressionMock;
+import org.apache.flink.table.planner.factories.TableFactoryHarness;
 import org.apache.flink.table.planner.factories.TestValuesTableFactory;
 import org.apache.flink.table.types.DataType;
 import org.apache.flink.table.types.logical.RawType;
 import org.apache.flink.test.util.AbstractTestBase;
+import org.apache.flink.testutils.junit.SharedObjects;
+import org.apache.flink.testutils.junit.SharedReference;
 import org.apache.flink.types.Either;
 import org.apache.flink.types.Row;
 import org.apache.flink.types.RowKind;
 import org.apache.flink.util.CloseableIterator;
 import org.apache.flink.util.CollectionUtil;
 import org.apache.flink.util.Collector;
 
+import org.jetbrains.annotations.NotNull;

Review comment:
       So far `@NotNull` is used very rarely across the Flink codebase and from 
various modules...
   
   I would favor to remove it here because in general I assume all return types 
are not null unless stated otherwise (i.e. `@Nullable`)

##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/DataStreamJavaITCase.java
##########
@@ -713,6 +732,106 @@ public void testMultiChangelogStreamUpsert() throws 
Exception {
                 resultStream, 0, Row.of(2, null, null, null), Row.of(1, 11.0, 
"1", "A"));
     }
 
+    @Test
+    public void testTimestampAPIConverterOperatorSinkRuntimeProvider() {
+        final StreamTableEnvironment tableEnv = 
StreamTableEnvironment.create(env);
+        final SharedReference<List<Long>> timestamps = sharedObjects.add(new 
ArrayList<>());
+        final Schema schema = schemaForTimeOperatorTesting();
+        final List<Row> rows =
+                Arrays.asList(
+                        Row.of(1, "foo", 
LocalDateTime.parse("2020-11-10T12:34:56.123")),
+                        Row.of(2, "foo", 
LocalDateTime.parse("2020-11-10T11:34:56.789")),
+                        Row.of(3, "foo", 
LocalDateTime.parse("2020-11-11T10:11:22.777")),
+                        Row.of(4, "foo", 
LocalDateTime.parse("2020-11-11T10:11:23.888")));
+
+        final TableDescriptor sourceDescriptor =
+                TableFactoryHarness.newBuilder()
+                        .schema(schema)
+                        .source(new TimestampTestSource(rows, ROW(INT(), 
STRING(), TIMESTAMP(3))))
+                        .sink(
+                                new TableFactoryHarness.SinkBase() {
+                                    @Override
+                                    public SinkRuntimeProvider 
getSinkRuntimeProvider(
+                                            Context context) {
+                                        return SinkProvider.of(
+                                                TestSink.newBuilder()
+                                                        .setWriter(new 
TestWriter(timestamps))
+                                                        
.setCommittableSerializer(
+                                                                
TestSink.StringCommittableSerializer
+                                                                        
.INSTANCE)
+                                                        .build());
+                                    }
+                                })
+                        .build();
+        tableEnv.createTable("T1", sourceDescriptor);
+        tableEnv.executeSql("INSERT INTO T1 SELECT * FROM 
T1").collect().forEachRemaining(l -> {});
+        assertTimestampResults(timestamps, rows);
+    }
+
+    @Test
+    public void testTimestampAPIConverterOperatorDataStreamSinkProvider() {
+        final StreamTableEnvironment tableEnv = 
StreamTableEnvironment.create(env);
+        final SharedReference<List<Long>> timestamps = sharedObjects.add(new 
ArrayList<>());
+        final Schema schema = schemaForTimeOperatorTesting();
+        final List<Row> rows =
+                Arrays.asList(
+                        Row.of(1, "foo", 
LocalDateTime.parse("2020-11-10T11:34:56.123")),
+                        Row.of(2, "foo", 
LocalDateTime.parse("2020-11-10T12:34:56.789")),
+                        Row.of(3, "foo", 
LocalDateTime.parse("2020-11-11T10:11:22.777")),
+                        Row.of(4, "foo", 
LocalDateTime.parse("2020-11-11T10:11:23.888")));
+
+        final TableDescriptor sourceDescriptor =
+                TableFactoryHarness.newBuilder()
+                        .schema(schema)
+                        .source(new TimestampTestSource(rows, ROW(INT(), 
STRING(), TIMESTAMP(3))))
+                        .sink(
+                                new TableFactoryHarness.SinkBase() {

Review comment:
       Nit: Maybe you can use it to get rid of the test sources classes.
   
   ```java
       tEnv.fromDataStream(
                           env.fromElements(...)
                                   .returns(...),
                           Schema.newBuilder()
                                   ...
                                   .build());
   ```
   Although I am not familiar with the best practices in the Table API ecosystem




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