xtern commented on code in PR #7640:
URL: https://github.com/apache/ignite-3/pull/7640#discussion_r2840364753
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItAlterTableDdlTest.java:
##########
@@ -240,6 +240,26 @@ public void doNotAllowFunctionsInNonPkColumns() {
);
}
+ @Test
+ public void cannotAddNonNullableColumnWithoutDefault() {
+ sql("CREATE TABLE t (id VARCHAR PRIMARY KEY)");
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Non-nullable column 'VAL' must have the default value",
+ () -> sql("ALTER TABLE t ADD COLUMN val VARCHAR NOT NULL")
+ );
+
+ assertThrowsSqlException(
+ STMT_VALIDATION_ERR,
+ "Non-nullable column 'VAL' must have the default value",
+ () -> sql("ALTER TABLE t ADD COLUMN val VARCHAR NOT NULL
DEFAULT NULL")
+ );
+
+ // Should not throw an exception since default value is provided.
+ sql("ALTER TABLE t ADD COLUMN val VARCHAR NOT NULL DEFAULT 'a'");
Review Comment:
> Let's check NOT NULL DEFAULT NULL case as well
This case is covered in test
`ItAlterTableDdlTest`.`cannotAddNonNullableColumnWithoutDefault`
> Do we have similar end2end test for ALTER COLUMN? like this?
> sql("ALTER TABLE test ALTER COLUMN val SET NOT NULL DEFAULT NULL");
Currently `ALTER COLUMN` has 2 limitations:
1. We don't support such syntax SET NOT NULL + DEFAULT (but we can SET
DEFAULT separately)
2. NULL -> NOT NULL is not allowed even if column has default
Should we create an issue to support NULL -> NOT NULL for column with
default?
--
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]