Francis Chuang created CALCITE-1197:
---------------------------------------
Summary: Support execute requests without parameters
Key: CALCITE-1197
URL: https://issues.apache.org/jira/browse/CALCITE-1197
Project: Calcite
Issue Type: Improvement
Components: avatica
Affects Versions: avatica-1.7.1
Reporter: Francis Chuang
Priority: Minor
If we execute a prepared statement without the {{parameterValues}} key, the
server returns a NullPointerException:
{code}
C:\Users\user
λ curl localhost:8765 -XPOST --data '{
"request": "execute",
"statementHandle": {
"connectionId": "my-conn",
"id": 25,
"signature": {
"columns": [
{
"ordinal": 0,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 0,
"signed": true,
"displaySize": 40,
"label": "K",
"columnName": "K",
"schemaName": "",
"precision": 0,
"scale": 0,
"tableName": "MY_TABLE",
"catalogName": "",
"type": {
"type": "scalar",
"id": -5,
"name": "BIGINT",
"rep": "PRIMITIVE_LONG"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.Long"
},
{
"ordinal": 1,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 1,
"signed": false,
"displaySize": 40,
"label": "V",
"columnName": "V",
"schemaName": "",
"precision": 0,
"scale": 0,
"tableName": "MY_TABLE",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "VARCHAR",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}
],
"sql": "SELECT * FROM my_table",
"parameters": [],
"cursorFactory": {
"style": "LIST",
"clazz": null,
"fieldNames": null
},
"statementType": null
}
},
"maxRowCount": 1
}'
{
"response": "error",
"exceptions": [
"java.lang.NullPointerException\n\tat
org.apache.calcite.avatica.jdbc.JdbcMeta.execute(JdbcMeta.java:806)\n\tat
org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:233)\n\tat
org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:950)\n\tat
org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:928)\n\tat
org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:102)\n\tat
org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:43)\n\tat
org.apache.calcite.avatica.server.AvaticaJsonHandler.handle(AvaticaJsonHandler.java:73)\n\tat
org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat
org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:245)\n\tat
org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat
java.lang.Thread.run(Thread.java:745)\n"
],
"errorMessage": "NullPointerException: (null exception message)",
"errorCode": -1,
"sqlState": "00000",
"severity": "UNKNOWN",
"rpcMetadata": {
"response": "rpcMetadata",
"serverAddress": "f826338-phoenix-server.f826338:8765"
}
}
{code}
The workaround is to always ensure that {{parameterValues: []}} is always
included.
However, it would improve the UX if {{parameterValues}} is actually optional as
per the documentation:
https://calcite.apache.org/docs/avatica_protobuf_reference.html#executerequest
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)