yuzelin commented on code in PR #1112:
URL: https://github.com/apache/incubator-paimon/pull/1112#discussion_r1189497925
##########
paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/SchemaChangeITCase.java:
##########
@@ -293,10 +304,40 @@ public void testModifyNullability() {
+ " `d` INT,\n"
+ " `e` FLOAT");
- assertThatThrownBy(() -> sql("ALTER TABLE T MODIFY c STRING NOT NULL"))
- .hasMessageContaining(
- "Could not execute ALTER TABLE PAIMON.default.T\n"
- + " MODIFY `c` STRING NOT NULL");
+ // Nullable -> not null
+ sql("ALTER TABLE T MODIFY c STRING NOT NULL");
+ result = sql("SHOW CREATE TABLE T");
+ assertThat(result.toString())
+ .contains(
+ "CREATE TABLE `PAIMON`.`default`.`T` (\n"
+ + " `a` VARCHAR(2147483647) NOT NULL,\n"
+ + " `b` VARCHAR(2147483647),\n"
+ + " `c` VARCHAR(2147483647) NOT NULL,\n"
+ + " `d` INT,\n"
+ + " `e` FLOAT");
+ assertThatThrownBy(
+ () ->
+ sql(
+ "INSERT INTO T VALUES('aaa', 'bbb',
CAST(NULL AS STRING), 1, CAST(NULL AS FLOAT))"))
+ .satisfies(
+ AssertionUtils.anyCauseMatches(
+ TableException.class,
+ "Column 'c' is NOT NULL, however, a null value
is being written into it."));
+
+ // Insert a null value
+ sql("INSERT INTO T VALUES('aaa', 'bbb', 'ccc', 1, CAST(NULL AS
FLOAT))");
+ result = sql("select * from T");
+ assertThat(result.toString()).isEqualTo("[+I[aaa, bbb, ccc, 1,
null]]");
+
+ // Then nullable -> not null
+ tEnv.getConfig()
+ .set(
+
ExecutionConfigOptions.TABLE_EXEC_SINK_NOT_NULL_ENFORCER,
+ ExecutionConfigOptions.NotNullEnforcer.DROP);
Review Comment:
This is important message. Currently, the doc `altering table - Changing
Column Nullability` only record how to change `not null` to `nullable`. Please
also document this usage for flink.
--
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]