danhuawang opened a new issue, #5655:
URL: https://github.com/apache/gravitino/issues/5655
### Version
main branch
### Describe what's wrong
ADD COLUMN NOT NULL as following, it failed.
I think the NULL value of the name column shouldn't impact add the column
"gender".
```
CREATE TABLE gt_postgresql.gt_db1.tb02 (
id INT,
name VARCHAR(50)
);
INSERT INTO gt_postgresql.gt_db1.tb02 (id, name) VALUES (1, NULL);
ALTER TABLE gt_postgresql.gt_db1.tb02 ADD COLUMN gender boolean NOT NULL;
```
### Error message and/or stacktrace
```
Query 20241123_041500_00061_vtd7v failed: Failed to operate object [tb02]
operation [ALTER] under [gt_db1], reason [ERROR: column "gender" of relation
"tb02" contains null values]
org.apache.gravitino.exceptions.GravitinoRuntimeException: ERROR: column
"gender" of relation "tb02" contains null values
at
org.apache.gravitino.catalog.postgresql.converter.PostgreSqlExceptionConverter.toGravitinoException(PostgreSqlExceptionConverter.java:47)
at
org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations.alterTable(JdbcTableOperations.java:311)
at
org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations.internalAlterTable(JdbcCatalogOperations.java:543)
at
org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations.alterTable(JdbcCatalogOperations.java:392)
at
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$alterTable$5(TableOperationDispatcher.java:202)
at
org.apache.gravitino.catalog.CatalogManager$CatalogWrapper.lambda$doWithTableOps$1(CatalogManager.java:151)
at
org.apache.gravitino.utils.IsolatedClassLoader.withClassLoader(IsolatedClassLoader.java:86)
at
org.apache.gravitino.catalog.CatalogManager$CatalogWrapper.doWithTableOps(CatalogManager.java:146)
at
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$alterTable$6(TableOperationDispatcher.java:201)
at
org.apache.gravitino.catalog.OperationDispatcher.doWithCatalog(OperationDispatcher.java:122)
at
org.apache.gravitino.catalog.TableOperationDispatcher.alterTable(TableOperationDispatcher.java:198)
at
org.apache.gravitino.hook.TableHookDispatcher.alterTable(TableHookDispatcher.java:100)
at
org.apache.gravitino.catalog.TableNormalizeDispatcher.alterTable(TableNormalizeDispatcher.java:93)
at
org.apache.gravitino.listener.TableEventDispatcher.alterTable(TableEventDispatcher.java:155)
at
org.apache.gravitino.server.web.rest.TableOperations.lambda$alterTable$5(TableOperations.java:197)
at
org.apache.gravitino.lock.TreeLockUtils.doWithTreeLock(TreeLockUtils.java:49)
```
### How to reproduce
In Trino CLI:
```
call gravitino.system.create_catalog(
'gt_postgresql',
'jdbc-postgresql',
map(
array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-database',
'jdbc-driver', 'trino.bypass.join-pushdown.strategy'],
array['jdbc:postgresql://10.20.31.19:5432/db', 'postgres',
'postgres', 'db', 'org.postgresql.Driver', 'EAGER']
)
);
CREATE SCHEMA gt_postgresql.gt_db1;
CREATE TABLE gt_postgresql.gt_db1.tb02 (
id INT,
name VARCHAR(50)
);
INSERT INTO gt_postgresql.gt_db1.tb02 (id, name) VALUES (1, NULL);
ALTER TABLE gt_postgresql.gt_db1.tb02 ADD COLUMN gender boolean NOT NULL;
```
### Additional context
_No response_
--
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]