Now that JDBC has a new explicitPrepare flag (Trino 431+) to use EXECUTE IMMEDIATE for prepared statements (Trino 418+), allow a new database option to use this (it is set on by default). This is achieved by a few changes:
In metabase-plugin.yaml the new option is added
In connectivity.clj the JDBC parameters are modified accordingly
In execute.clj a PreparedStatement proxy is returned. This is because Metabase calls getParameterMetaData() which would negate the upsides of EXECUTE IMMEDIATE. This is used by Metabase just to count the number of arguments to issue a message. Not defining getParameterMetaData() in the proxy is not an issue because 1) Metabase has a try/catch when calling this method and 2) we issue the exact same error message, except we do it after the query is executed
Two custom error messages are introduced in case customers are using a version of Trino older than 418. The first one when defining a connection (starburst.clj), where we know that if we get a Expecting: 'USING' error when testing the connection it's because of an incompatible Trino version. The second one when running a query (e.g. the customer downgrades Trino after setting up the connection) in which case this may be the issue but we cannot be certain (handle-execution-error method in execute.clj)
As far as testing goes, we are running the whole Metabase test suite against both options (hence a modification in Makefile). The downside is that we are running many tests which are independent of the explicitPrepare option.
New flag when defining a connection (including error message):
Error message when a query fails with Expecting: 'USING':
Now that JDBC has a new
explicitPrepare
flag (Trino 431+) to useEXECUTE IMMEDIATE
for prepared statements (Trino 418+), allow a new database option to use this (it is set on by default). This is achieved by a few changes:metabase-plugin.yaml
the new option is addedconnectivity.clj
the JDBC parameters are modified accordinglyexecute.clj
aPreparedStatement
proxy is returned. This is because Metabase callsgetParameterMetaData()
which would negate the upsides ofEXECUTE IMMEDIATE
. This is used by Metabase just to count the number of arguments to issue a message. Not defininggetParameterMetaData()
in the proxy is not an issue because 1) Metabase has a try/catch when calling this method and 2) we issue the exact same error message, except we do it after the query is executedstarburst.clj
), where we know that if we get aExpecting: 'USING'
error when testing the connection it's because of an incompatible Trino version. The second one when running a query (e.g. the customer downgrades Trino after setting up the connection) in which case this may be the issue but we cannot be certain (handle-execution-error
method inexecute.clj
)As far as testing goes, we are running the whole Metabase test suite against both options (hence a modification in
Makefile
). The downside is that we are running many tests which are independent of theexplicitPrepare
option.New flag when defining a connection (including error message):
Error message when a query fails with
Expecting: 'USING'
: