docete commented on a change in pull request #14977: URL: https://github.com/apache/flink/pull/14977#discussion_r581667233
########## File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/runtime/stream/table/TableSinkITCase.scala ########## @@ -838,6 +842,311 @@ class TableSinkITCase extends StreamingTestBase { } + @Test + def testPartialInsert(): Unit = { + tEnv.executeSql( + s""" + |CREATE TABLE testSink ( + | `a` INT, + | `b` DOUBLE + |) + |WITH ( + | 'connector' = 'values', + | 'sink-insert-only' = 'false' + |) + |""".stripMargin) + + val t = env.fromCollection(tupleData2).toTable(tEnv, 'x, 'y) + tEnv.createTemporaryView("MyTable", t) + + tEnv.executeSql( + s""" + |INSERT INTO testSink (b) + |SELECT sum(y) FROM MyTable GROUP BY x + |""".stripMargin).await() + val expected = List( + "null,0.1", + "null,0.4", + "null,1.0", + "null,2.2", + "null,3.9") + val result = TestValuesTableFactory.getResults("testSink") + assertEquals(expected.sorted, result.sorted) + } + + @Test + def testPartialInsertWithNotNullColumn(): Unit = { + tEnv.executeSql( + s""" + |CREATE TABLE testSink ( + | `a` INT NOT NULL, + | `b` DOUBLE + |) + |WITH ( + | 'connector' = 'values', + | 'sink-insert-only' = 'false' + |) + |""".stripMargin) + + val t = env.fromCollection(tupleData2).toTable(tEnv, 'x, 'y) + tEnv.createTemporaryView("MyTable", t) + + expectedEx.expect(classOf[ValidationException]) + expectedEx.expectMessage("Column 'a' has no default value and does not allow NULLs") Review comment: Check the error msg again and found the original one is more accuracy. So i will revert the change. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org