fhueske commented on code in PR #30220:
URL: https://github.com/apache/flink/pull/30220#discussion_r4771935703
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/TableSourceITCase.scala:
##########
@@ -514,6 +514,52 @@ class TableSourceITCase extends StreamingTestBase {
innerTestSetParallelism("SourceFunction", validParallelism, index =
index.getAndIncrement)
}
+ private def registerNullableNestedTable(): Unit = {
+ val dataId = TestValuesTableFactory.registerData(
+ Seq(row(1, null), row(2, row(5, "x", 7)), row(3, row(6, "y", 8))))
+ tEnv.executeSql(s"""
+ |CREATE TABLE NullableNestedTable (
+ | id INT,
+ | ns ROW<v INT NOT NULL, w STRING, u INT>
+ |) WITH (
+ | 'connector' = 'values',
+ | 'nested-projection-supported' = 'true',
+ | 'data-id' = '$dataId',
+ | 'bounded' = 'true'
+ |)
+ |""".stripMargin)
+ }
+
+ private def collectNullableNested(query: String): Seq[String] = {
+ val sink = new TestingAppendSink
+ tEnv.sqlQuery(query).toDataStream.addSink(sink)
+ env.execute()
+ sink.getAppendResults.sorted
+ }
+
+ @Test
+ def testNestedProjectionOfNotNullFieldOfNullableRow(): Unit = {
+ registerNullableNestedTable()
+ val result = collectNullableNested("SELECT id, ns.v, ns.w FROM
NullableNestedTable")
+ assertThat(result).isEqualTo(Seq("1,null,null", "2,5,x", "3,6,y").sorted)
+ }
+
+ @Test
+ def testNestedProjectionOfNotNullFieldOfNullableRowInExpression(): Unit = {
+ registerNullableNestedTable()
+ val result = collectNullableNested("SELECT id, ns.v + 1, ns.w FROM
NullableNestedTable")
+ assertThat(result).isEqualTo(Seq("1,null,null", "2,6,x", "3,7,y").sorted)
+ }
+
+ @Test
+ def testNestedProjectionOfNotNullFieldOfNullableRowIsNull(): Unit = {
+ registerNullableNestedTable()
+ val result = collectNullableNested(
+ "SELECT id, ns.v IS NULL, COALESCE(ns.v, -1), ns.w FROM
NullableNestedTable")
+ assertThat(result)
+ .isEqualTo(Seq("1,true,-1,null", "2,false,5,x", "3,false,6,y").sorted)
+ }
Review Comment:
Yes, makes sense. Thanks!
--
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]