jaydebeapi icon indicating copy to clipboard operation
jaydebeapi copied to clipboard

presto jdbc execute long sql got error "Request Header Fields Too Large"

Open mirafranc opened this issue 5 years ago • 1 comments

Getting "Request Header Fields Too Large" when query exceeds 11000 characters. driver: presto-jdbc-338-e.3.jar - io.prestosql.jdbc.PrestoDriver

Caused by: java.lang.RuntimeException: returned an invalid response: JsonResponse{statusCode=400, statusMessage=Bad Request, headers= {connection=[close], content-length=[198], content-type=[text/html], date=[Mon, 01 Feb 2021 20:15:52 GMT], server=[awselb/2.0]} , hasValue=false} [Error:

400 Request Header Or Cookie Too Large

Similar exception reported here: https://github.com/prestodb/presto/issues/13097 We tried recommended solution by adding 'http-server.max-request-header-size=5MB' in config.properties with no effect.

mirafranc avatar Feb 05 '21 21:02 mirafranc

After deeper investigation of DBeaver (works without issue), Spark and JayDeBeApi there are two ways how to execute SQL statement by JDBC:

  1. As prepared statement (used by Spark and JayDeBeApi ): statement = connection.prepareStatement(sql) statement.executeQuery()
  2. As statement (used by DBeaver): connection.createStatement() statement.executeQuery(sql)

switching to create statement works correctly for Presto (Trino). tested locally using DBs based on drivers: presto-jdbc-338.jar ojdbc6-11.2.0.4.jar ojdbc7-12.1.0.2.jar ojdbc14-8.1.7.1.jar ojdbc14-10.2.0.5.jar pijdbcdriver-2019.0.0.jar ngdbc-2.4.59.jar sqljdbc4-2.0.jar terajdbc.16.20.00.12.jar

Issue is caused by wrong driver implementation of prepareStatement in Presto (Trino), anyway DBeaver query approach would be alternative way.

mirafranc avatar Feb 05 '21 22:02 mirafranc