Francis Chuang created CALCITE-1196: ---------------------------------------
Summary: Cache statement handle signatures for prepared statements so that the client won't have to send them during execution Key: CALCITE-1196 URL: https://issues.apache.org/jira/browse/CALCITE-1196 Project: Calcite Issue Type: Improvement Components: avatica Affects Versions: avatica-1.7.1 Reporter: Francis Chuang Priority: Minor With avatica 1.7.1, to prepare and execute a statement, we need to do the following (shown using curl): {code} C:\Users\user λ curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": "my-conn","sql": "SELECT * FROM my_table","maxRowCount": 1}' { "response": "prepare", "statement": { "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 } }, "rpcMetadata": { "response": "rpcMetadata", "serverAddress": "f826338-phoenix-server.f826338:8765" } } 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 } }, "parameterValues": [], "maxRowCount": 1 }' {code} Notice that we receive the signature in the {{statementHandle}} when running a prepare request. We then attach this so the execute request to execute the statement. The UX can be improved by caching that signature on the server along with the prepared statement to avoid having to ask the client to send it with the execution request. -- This message was sent by Atlassian JIRA (v6.3.4#6332)