Skip to content

Instantly share code, notes, and snippets.

@y-lan
Forked from electrum/Presto_REST_API.md
Created December 10, 2013 04:44
Show Gist options
  • Save y-lan/7885836 to your computer and use it in GitHub Desktop.
Save y-lan/7885836 to your computer and use it in GitHub Desktop.
  • Make a POST to /v1/statement with the query
  • You get back a JSON document that might contain a nextUri link
  • The document will contain columns if available
  • The document will contain data if available
  • The columns field will always be set if data is set (and usually earlier)
  • If there is no nextUri link, then the query is finished (either successfully completed or failed). The status field is for information only. It should not be used to determine whether the query is finished
  • Otherwise, keep following the nextUri link
  • The document will contain an error field if the query has failed — this is how you distinguish between a successfully completed query and a failed query when there is no more nextUri link
  • If the response is an HTTP 503, sleep 50-100ms and try again
  • Otherwise, if the response is anything other than an HTTP 200 with Content-Type application/json, then consider the query failed (this means something has gone wrong, for example, you might receive a 404 or 410)
  • The document format is exactly the same for the POST response and the nextUri link response — you might get data immediately as a response to the POST, or it might take requests for a longer query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment