Skip to content

Instantly share code, notes, and snippets.

@electrum
Last active November 14, 2017 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save electrum/a382d3f8e10fde5e2e0c1bfc1ea3182f to your computer and use it in GitHub Desktop.
Save electrum/a382d3f8e10fde5e2e0c1bfc1ea3182f to your computer and use it in GitHub Desktop.
Presto protocol enhancements

The current protocol uses HTTP headers for many things including session parameters, session properties, transaction info, prepared statements, etc. This is problematic for prepared statements due to length limitations on HTTP headers in various clients and servers. It is also makes the protocol harder to following by mixing things across headers and the request / response bodies.

As long as we're changing the protocol, it makes sense to move everything from headers into the JSON documents. We will add a new endpoint, /v2/statement, that accepts application/json with the new request body (instead of just the query text). The new endpoint will return the new response format.

Request document:

{
    "session": {
        "user": "bob",
        "source": "cli",
        "clientInfo": "junk",
        "catalog": "tpch",
        "schema": "sf10",
        "timeZone": "UTC",
        "language": "en-US",
        "transactionId": "tx123",
        "properties": {
            "query_max_run_time": "30s",
            "hive.bucket_execution_enabled": "true"
        },
        "preparedStatements": {
            "abc": "data",
            "xyz": "data"
        }
    },
    "query": "SELECT ..."
}

Response document (same as existing, with the addition of the actions field):

{
    "id": "query12345",
    "columns": [],
    "data": [],
    "actions": {
        "setTransactionId": "tx123",
        "clearTransactionId": true,
        "setSessionProperties": {
            "query_max_run_time": "30s",
            "hive.bucket_execution_enabled": "true"
        },
        "clearSessionProperties": [
            "query_max_run_time",
            "hive.bucket_execution_enabled"
        ],
        "addPreparedStatements": {
            "abc": "data",
            "xyz": "data"
        },
        "deallocatePreparedStatements": [
            "abc",
            "xyz"
        ]
    }
}
@ilfrin
Copy link

ilfrin commented Nov 14, 2017

Was wondering if adding a version field would be any useful for the future.
It would serve as a minor version, since the major is in the endpoint address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment