apache / gravitino

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
https://gravitino.apache.org
Apache License 2.0
1.09k stars 343 forks source link

[Bug report] Trino, hive catalog: COMMNET COLUMN with ' ' or NULL has ArrayIndexOutOfBoundsException error #5533

Open danhuawang opened 1 week ago

danhuawang commented 1 week ago

Version

main branch

Describe what's wrong

trino:company> COMMENT ON COLUMN test_table.name IS ' ';
Query 20241111_081934_02188_de6jj failed: Index 1 out of bounds for length 1
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
    at java.base/java.util.ImmutableCollections$ListN.get(ImmutableCollections.java:687)
    at org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadata.applyAlter(CatalogConnectorMetadata.java:194)
    at org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadata.setColumnComment(CatalogConnectorMetadata.java:245)
    at org.apache.gravitino.trino.connector.GravitinoMetadata.setColumnComment(GravitinoMetadata.java:317)
    at io.trino.tracing.TracingConnectorMetadata.setColumnComment(TracingConnectorMetadata.java:475)
    at io.trino.metadata.MetadataManager.setColumnComment(MetadataManager.java:882)
    at io.trino.tracing.TracingMetadata.setColumnComment(TracingMetadata.java:460)
    at io.trino.execution.CommentTask.commentOnColumn(CommentTask.java:168)
    at io.trino.execution.CommentTask.execute(CommentTask.java:80)
    at io.trino.execution.CommentTask.execute(CommentTask.java:45)
    at io.trino.execution.DataDefinitionExecution.start(DataDefinitionExecution.java:145)
    at io.trino.execution.SqlQueryManager.createQuery(SqlQueryManager.java:256)
    at io.trino.dispatcher.LocalDispatchQuery.startExecution(LocalDispatchQuery.java:145)
    at io.trino.dispatcher.LocalDispatchQuery.lambda$waitForMinimumWorkers$2(LocalDispatchQuery.java:129)
    at io.airlift.concurrent.MoreFutures.lambda$addSuccessCallback$12(MoreFutures.java:568)
    at io.airlift.concurrent.MoreFutures$3.onSuccess(MoreFutures.java:543)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1133)
    at io.trino.$gen.Trino_435____20241111_020150_2.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583)

trino:company> COMMENT ON COLUMN test_table.name IS NULL
            -> ;
Query 20241111_082134_02199_de6jj failed: Index 1 out of bounds for length 1
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
    at java.base/java.util.ImmutableCollections$ListN.get(ImmutableCollections.java:687)
    at org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadata.applyAlter(CatalogConnectorMetadata.java:194)
    at org.apache.gravitino.trino.connector.catalog.CatalogConnectorMetadata.setColumnComment(CatalogConnectorMetadata.java:245)
    at org.apache.gravitino.trino.connector.GravitinoMetadata.setColumnComment(GravitinoMetadata.java:317)
    at io.trino.tracing.TracingConnectorMetadata.setColumnComment(TracingConnectorMetadata.java:475)
    at io.trino.metadata.MetadataManager.setColumnComment(MetadataManager.java:882)
    at io.trino.tracing.TracingMetadata.setColumnComment(TracingMetadata.java:460)
    at io.trino.execution.CommentTask.commentOnColumn(CommentTask.java:168)
    at io.trino.execution.CommentTask.execute(CommentTask.java:80)
    at io.trino.execution.CommentTask.execute(CommentTask.java:45)
    at io.trino.execution.DataDefinitionExecution.start(DataDefinitionExecution.java:145)
    at io.trino.execution.SqlQueryManager.createQuery(SqlQueryManager.java:256)
    at io.trino.dispatcher.LocalDispatchQuery.startExecution(LocalDispatchQuery.java:145)
    at io.trino.dispatcher.LocalDispatchQuery.lambda$waitForMinimumWorkers$2(LocalDispatchQuery.java:129)
    at io.airlift.concurrent.MoreFutures.lambda$addSuccessCallback$12(MoreFutures.java:568)
    at io.airlift.concurrent.MoreFutures$3.onSuccess(MoreFutures.java:543)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1133)
    at io.trino.$gen.Trino_435____20241111_020150_2.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1583)

Error message and/or stacktrace

N/A

How to reproduce

  1. create table
    
    CREATE TABLE test_table (
    id INTEGER COMMENT 'Primary identifier for the record',
    name VARCHAR COMMENT 'Name of the person',
    age INTEGER COMMENT 'Age of the person'
    );

2.`COMMENT ON COLUMN test_table.name IS 'a'`
3. `COMMENT ON COLUMN test_table.name IS ' ';`
4. `COMMENT ON COLUMN test_table.name IS NULL`

### Additional context

_No response_
danhuawang commented 1 week ago

@diqiu50 Can you help check this issue?