trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.49k stars 3.02k forks source link

Unable to update Postgresql column to null in Trino #24204

Open qikijames opened 1 day ago

qikijames commented 1 day ago

Getting the error message "Value is missing" when an SQL update attempts to set a NULLABLE column to NULL.

trino:public> update test set updated_by=null  where id='f75afcdb-6545-4675-b341-4fdf17a9d14b';

Query 20241120_170254_00032_x2wwq, FAILED, 1 node
Splits: 1 total, 0 done (0.00%)
0.04 [0 rows, 0B] [0 rows/s, 0B/s]

Query 20241120_170254_00032_x2wwq failed: Value is missing

The same command works when directly use the psql.

db=# update test set updated_by=null where id='f75afcdb-6545-4675-b341-4fdf17a9d14b';
UPDATE 1

Trino version: 462 Postgresql server 16.4

wendigo commented 1 day ago

@ebyhr ptal

ebyhr commented 1 day ago

Here's the full stacktrace:

Query 20241120_233613_00032_py2uc failed: Value is missing
com.google.common.base.VerifyException: Value is missing
    at io.trino.plugin.jdbc.DefaultQueryBuilder.lambda$prepareStatement$12(DefaultQueryBuilder.java:295)
    at java.base/java.util.Optional.orElseThrow(Optional.java:403)
    at io.trino.plugin.jdbc.DefaultQueryBuilder.prepareStatement(DefaultQueryBuilder.java:295)
    at io.trino.plugin.postgresql.PostgreSqlClient.update(PostgreSqlClient.java:967)
    at io.trino.plugin.jdbc.ForwardingJdbcClient.update(ForwardingJdbcClient.java:480)
    at io.trino.plugin.jdbc.jmx.StatisticsAwareJdbcClient.lambda$update$51(StatisticsAwareJdbcClient.java:500)
    at io.trino.plugin.jdbc.jmx.JdbcApiStats.wrap(JdbcApiStats.java:34)
    at io.trino.plugin.jdbc.jmx.StatisticsAwareJdbcClient.update(StatisticsAwareJdbcClient.java:500)
    at io.trino.plugin.jdbc.RetryingJdbcClient.update(RetryingJdbcClient.java:510)
    at io.trino.plugin.jdbc.CachingJdbcClient.update(CachingJdbcClient.java:638)
    at io.trino.plugin.jdbc.CachingJdbcClient.update(CachingJdbcClient.java:638)
    at io.trino.plugin.jdbc.DefaultJdbcMetadata.executeUpdate(DefaultJdbcMetadata.java:1312)
    at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata.executeUpdate(ClassLoaderSafeConnectorMetadata.java:757)
    at io.trino.tracing.TracingConnectorMetadata.executeUpdate(TracingConnectorMetadata.java:895)
    at io.trino.metadata.MetadataManager.executeUpdate(MetadataManager.java:1322)
    at io.trino.tracing.TracingMetadata.executeUpdate(TracingMetadata.java:775)
    at io.trino.sql.planner.LocalExecutionPlanner$Visitor.lambda$visitTableUpdate$63(LocalExecutionPlanner.java:3638)
    at io.trino.operator.TableMutationOperator.getOutput(TableMutationOperator.java:122)
    at io.trino.operator.Driver.processInternal(Driver.java:403)
    at io.trino.operator.Driver.lambda$process$8(Driver.java:306)
    at io.trino.operator.Driver.tryWithLock(Driver.java:709)
    at io.trino.operator.Driver.process(Driver.java:298)
    at io.trino.operator.Driver.processForDuration(Driver.java:269)
    at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:890)
    at io.trino.execution.executor.dedicated.SplitProcessor.run(SplitProcessor.java:77)
    at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.lambda$run$0(TaskEntry.java:201)
    at io.trino.$gen.Trino_testversion____20241120_233436_71.run(Unknown Source)
    at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.run(TaskEntry.java:202)
    at io.trino.execution.executor.scheduler.FairScheduler.runTask(FairScheduler.java:172)
    at io.trino.execution.executor.scheduler.FairScheduler.lambda$submit$0(FairScheduler.java:159)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
    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:1575)