Skip to content

Presto JDBC driver for watsonx iceberg fails with "Catalog iceberg_data only supports writes using autocommit" even though Presto allows to set databaseConnection.setAutcommit(false) #25522

@RashmiBharadwaj

Description

@RashmiBharadwaj

Presto JDBC driver supports setting databaseConnection.setAutcommit(false), but then when I run a query like "insert into table values(...)", the query fails with error: Catalog iceberg_data only supports writes using autocommit.

I am using a presto jdbc driver presto-jdbc-0.292.jar, to connect to watsonx.data cpd version 2.1.3.
Iceberg connector is used here.

Sample java code to reproduce the issue:

String presto_url = "jdbc:presto://:8443/iceberg_data?SSL=true&SSLTrustStorePath=<cert_path>";
String driverClass = "com.facebook.presto.jdbc.PrestoDriver";
Class.forName(driverClass);
/** Set the connection properties**/
Properties properties = new Properties();
properties.setProperty("user", username);
properties.setProperty("password", password);

/** Connect **/
connection = DriverManager.getConnection(presto_url, properties);

DatabaseMetaData databaseMetaData = connection.getMetaData();
System.out.println("databaseMetaData.supportsTransactions(): " + databaseMetaData.supportsTransactions());
if(databaseMetaData.supportsTransactions())
{
connection.setAutoCommit(false);
}

System.out.println("connection.getAutoCommit(): " + connection.getAutoCommit());
Statement st = connection.createStatement();

String query = "insert into s33.t1 values(1,'a')";
System.out.println(query);
st.execute(query);

Error:

databaseMetaData.supportsTransactions(): true
connection.getAutoCommit(): false
insert into s33.t1 values(1,'a')
java.sql.SQLException: Query failed (#20250711_072159_00075_tn25v): Catalog iceberg_data only supports writes using autocommit
at com.facebook.presto.jdbc.PrestoResultSet.resultsException(PrestoResultSet.java:1841)
at com.facebook.presto.jdbc.PrestoResultSet.getColumns(PrestoResultSet.java:1751)
at com.facebook.presto.jdbc.PrestoResultSet.(PrestoResultSet.java:121)
at com.facebook.presto.jdbc.PrestoStatement.internalExecute(PrestoStatement.java:272)
at com.facebook.presto.jdbc.PrestoStatement.execute(PrestoStatement.java:230)
at sampletest.samplewatsonx3.main(samplewatsonx3.java:50)
Caused by: com.facebook.presto.spi.PrestoException: Catalog iceberg_data only supports writes using autocommit
at com.facebook.presto.transaction.InMemoryTransactionManager$TransactionMetadata.checkConnectorWrite(InMemoryTransactionManager.java:561)
at com.facebook.presto.transaction.InMemoryTransactionManager.checkConnectorWrite(InMemoryTransactionManager.java:273)
at com.facebook.presto.transaction.InMemoryTransactionManager.getCatalogMetadataForWrite(InMemoryTransactionManager.java:236)
at com.facebook.presto.metadata.MetadataManager.getCatalogMetadataForWrite(MetadataManager.java:1767)
at com.facebook.presto.metadata.MetadataManager.getInsertLayout(MetadataManager.java:828)
at com.facebook.presto.sql.planner.LogicalPlanner.buildInternalInsertPlan(LogicalPlanner.java:364)
at com.facebook.presto.sql.planner.LogicalPlanner.createInsertPlan(LogicalPlanner.java:307)
at com.facebook.presto.sql.planner.LogicalPlanner.planStatementWithoutOutput(LogicalPlanner.java:175)
at com.facebook.presto.sql.planner.LogicalPlanner.planStatement(LogicalPlanner.java:157)
at com.facebook.presto.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:140)
at com.facebook.presto.sql.analyzer.BuiltInQueryAnalyzer.plan(BuiltInQueryAnalyzer.java:127)
at com.facebook.presto.execution.SqlQueryExecution.lambda$createLogicalPlanAndOptimize$2(SqlQueryExecution.java:554)
at com.facebook.presto.common.RuntimeStats.profileNanos(RuntimeStats.java:136)
at com.facebook.presto.execution.SqlQueryExecution.createLogicalPlanAndOptimize(SqlQueryExecution.java:552)
at com.facebook.presto.execution.SqlQueryExecution.start(SqlQueryExecution.java:474)
at com.facebook.presto.$gen.Presto_0_286____20250707_040312_1.run(Unknown Source)
at com.facebook.presto.execution.SqlQueryManager.createQuery(SqlQueryManager.java:320)
at com.facebook.presto.dispatcher.LocalDispatchQuery.lambda$startExecution$8(LocalDispatchQuery.java:214)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:839)

Expected Behavior

Since the driver returns true for supportsTransactions(), query should work when autocommit is disabled, or presto has to return false when supportsTransactions() is called. Or presto should not allow users to change autocommit for a connection.

Context

In our application, we are using JDBC's DatabaseMetaData.supportsTransactions() to check if setting autocommit to false is allowed. There is no specific check based on driver type. Is there a way users can detect if setting autocommit is allowed or not for presto when connecting to watsonx.data/iceberg connector?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🆕 Unprioritized

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions