danhuawang opened a new issue, #5656:
URL: https://github.com/apache/gravitino/issues/5656
### Version
main branch
### Describe what's wrong
I can't create table including ARRAY data type in Trino when I use the PG
catalog.
```
trino:db3> CREATE TABLE tb02 (int_array ARRAY(INTEGER));
Query 20241123_052630_00342_zc3ii failed: Failed to operate table(s) [tb02]
operation [CREATE] under schema [db3], reason [PostgreSQL doesn't support
element to nullable]
java.lang.IllegalArgumentException: PostgreSQL doesn't support element to
nullable
```
And it works when I use the original postgresql connector to create the same
table
```
trino:cndb1> create catalog pg_conn1 using postgresql with
("connection-url"='jdbc:postgresql://10.20.31.19:5432/db',"connection-user"='postgres',"connection-password"='postgre
s',"postgresql.array-mapping"='AS_ARRAY');
CREATE CATALOG
trino:cndb1> create schema pg_conn1.db2;
CREATE SCHEMA
trino:cndb1> use pg_conn1.db2;
USE
trino:db2> CREATE TABLE cntb01 (int_array ARRAY(INTEGER));
CREATE TABLE
trino:db2> INSERT INTO cntb01 VALUES (ARRAY[1, 2, 3]), (ARRAY[4, 5, NULL,
7]), (ARRAY[]);
INSERT: 3 rows
Query 20241123_052044_00299_zc3ii, FINISHED, 1 node
Splits: 35 total, 35 done (100.00%)
0.22 [0 rows, 0B] [0 rows/s, 0B/s]
trino:db2> select * from cntb01;
int_array
-----------------
[1, 2, 3]
[4, 5, NULL, 7]
[]
(3 rows)
```
### Error message and/or stacktrace
```
trino:db3> CREATE TABLE tb02 (int_array ARRAY(INTEGER));
Query 20241123_052630_00342_zc3ii failed: Failed to operate table(s) [tb02]
operation [CREATE] under schema [db3], reason [PostgreSQL doesn't support
element to nullable]
java.lang.IllegalArgumentException: PostgreSQL doesn't support element to
nullable
at
com.google.common.base.Preconditions.checkArgument(Preconditions.java:143)
at
org.apache.gravitino.catalog.postgresql.converter.PostgreSqlTypeConverter.fromGravitinoArrayType(PostgreSqlTypeConverter.java:142)
at
org.apache.gravitino.catalog.postgresql.converter.PostgreSqlTypeConverter.fromGravitino(PostgreSqlTypeConverter.java:125)
at
org.apache.gravitino.catalog.postgresql.converter.PostgreSqlTypeConverter.fromGravitino(PostgreSqlTypeConverter.java:28)
at
org.apache.gravitino.catalog.postgresql.operation.PostgreSqlTableOperations.appendColumnDefinition(PostgreSqlTableOperations.java:264)
at
org.apache.gravitino.catalog.postgresql.operation.PostgreSqlTableOperations.generateCreateTableSql(PostgreSqlTableOperations.java:172)
at
org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations.create(JdbcTableOperations.java:109)
at
org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations.createTable(JdbcCatalogOperations.java:457)
at
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$internalCreateTable$21(TableOperationDispatcher.java:485)
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$internalCreateTable$22(TableOperationDispatcher.java:483)
at
org.apache.gravitino.catalog.OperationDispatcher.doWithCatalog(OperationDispatcher.java:122)
at
org.apache.gravitino.catalog.TableOperationDispatcher.internalCreateTable(TableOperationDispatcher.java:480)
at
org.apache.gravitino.catalog.TableOperationDispatcher.lambda$createTable$4(TableOperationDispatcher.java:170)
at
org.apache.gravitino.lock.TreeLockUtils.doWithTreeLock(TreeLockUtils.java:49)
at
org.apache.gravitino.catalog.TableOperationDispatcher.createTable(TableOperationDispatcher.java:166)
at
org.apache.gravitino.hook.TableHookDispatcher.createTable(TableHookDispatcher.java:81)
at
org.apache.gravitino.catalog.TableNormalizeDispatcher.createTable(TableNormalizeDispatcher.java:78)
at
org.apache.gravitino.listener.TableEventDispatcher.createTable(TableEventDispatcher.java:136)
at
org.apache.gravitino.server.web.rest.TableOperations.lambda$createTable$2(TableOperations.java:124)
at
java.base/java.security.AccessController.doPrivileged(AccessController.java:714)
at java.base/javax.security.auth.Subject.doAs(Subject.java:525)
at
org.apache.gravitino.utils.PrincipalUtils.doAs(PrincipalUtils.java:39)
at org.apache.gravitino.server.web.Utils.doAs(Utils.java:188)
at
org.apache.gravitino.server.web.rest.TableOperations.createTable(TableOperations.java:116)
```
### How to reproduce
In Trino CLI:
```
call gravitino.system.create_catalog(
'gt_pg1',
'jdbc-postgresql',
map(
array['jdbc-url', 'jdbc-user', 'jdbc-password', 'jdbc-database',
'jdbc-driver', 'trino.bypass.join-pushdown.strategy',
'trino.bypass.postgresql.array-mapping'],
array['jdbc:postgresql://10.20.31.19:5432/db', 'postgres',
'postgres', 'db', 'org.postgresql.Driver', 'EAGER', 'AS_ARRAY']
)
);
create schema gt_pg1.db3;
use gt_pg1.db3;
CREATE TABLE tb02 (int_array ARRAY(INTEGER))
```
### 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]