AMashenkov commented on code in PR #7640:
URL: https://github.com/apache/ignite-3/pull/7640#discussion_r2840163627
##########
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:
Lets also check here
```suggestion
sql("ALTER TABLE t ADD COLUMN val VARCHAR DEFAULT NULL");
```
Seems, we have no end-to-end test for such case.
Do we have similar end2end test for ALTER COLUMN? like this?
```
sql("ALTER TABLE test ALTER COLUMN val SET NOT NULL DEFAULT NULL");
```
--
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]