matriv commented on a change in pull request #17811:
URL: https://github.com/apache/flink/pull/17811#discussion_r753447798



##########
File path: 
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/table/TableSinkITCase.scala
##########
@@ -635,6 +635,58 @@ class TableSinkITCase extends StreamingTestBase {
     assertEquals(expected.sorted, result.sorted)
   }
 
+  @Test
+  def testCharPrecisionEnforcer(): Unit = {
+    val dataId = TestValuesTableFactory.registerData(data3)
+    tEnv.executeSql(
+      s"""
+         |CREATE TABLE char_src (
+         |  id INT,
+         |  shopId BIGINT,
+         |  txt CHAR(9)
+         |) WITH (
+         |  'connector' = 'values',
+         |  'data-id' = '$dataId'
+         |)
+         |""".stripMargin)
+    tEnv.executeSql(
+      s"""
+         |CREATE TABLE char_sink (
+         |  id INT,
+         |  shopId BIGINT,
+         |  txt CHAR(9)
+         |) WITH (
+         |  'connector' = 'values',
+         |  'sink-insert-only' = 'true'
+         |)
+         |""".stripMargin)
+
+    // default should fail, because there are char values exceeding the length 
specified
+    try {
+      tEnv.executeSql("INSERT INTO char_sink SELECT * FROM char_src").await()
+      fail("Execution should fail.")
+    } catch {
+      case t: Throwable =>
+        val exception = ExceptionUtils.findThrowableWithMessage(
+          t,
+          "Column 'txt' is of CHAR/VARCHAR type with a length of '9', however, 
a string " +

Review comment:
       True, changed to just to values `IGNORE` and `TRIM`




-- 
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...@flink.apache.org

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


Reply via email to