Presto 服务的所有请求都应该使用 Presto REST API v1 版本。
若要请求服务,请使用显式的 URL 。 你需要在发送请求前更新 presto.service:8081
。
欲了解更多关于 headers 的信息,请参阅 PrestoHeaders。
Schema
你可以在 HTTP 正文中使用语句。 所有数据都是作为 JSON 文档收到的,它可能包含一个 next Uri
链接。 如果收到的 JSON 文档包含一个 nextUri
链接, 请求继续使用 nextUri
链接,直到收到的数据不包含 nextUri
链接。 如果没有返回错误,则查询成功。 如果一个 错误
字段显示在 统计信息
中,这意味着查询失败。
➜ ~ curl --header "X-Presto-User: test-user" --request POST --data 'show catalogs' http://localhost:8081/v1/statement
{
"infoUri" : "http://localhost:8081/ui/query.html?20191113_033653_00006_dg6hb",
"stats" : {
"queued" : true,
"nodes" : 0,
"userTimeMillis" : 0,
"cpuTimeMillis" : 0,
"wallTimeMillis" : 0,
"processedBytes" : 0,
"processedRows" : 0,
"runningSplits" : 0,
"queuedTimeMillis" : 0,
"queuedSplits" : 0,
"completedSplits" : 0,
"totalSplits" : 0,
"scheduled" : false,
"peakMemoryBytes" : 0,
"state" : "QUEUED",
"elapsedTimeMillis" : 0
},
"id" : "20191113_033653_00006_dg6hb",
"nextUri" : "http://localhost:8081/v1/statement/20191113_033653_00006_dg6hb/1"
}
➜ ~ curl http://localhost:8081/v1/statement/20191113_033653_00006_dg6hb/1
{
"infoUri" : "http://localhost:8081/ui/query.html?20191113_033653_00006_dg6hb",
"nextUri" : "http://localhost:8081/v1/statement/20191113_033653_00006_dg6hb/2",
"id" : "20191113_033653_00006_dg6hb",
"stats" : {
"state" : "PLANNING",
"totalSplits" : 0,
"queued" : false,
"userTimeMillis" : 0,
"completedSplits" : 0,
"scheduled" : false,
"wallTimeMillis" : 0,
"runningSplits" : 0,
"cpuTimeMillis" : 0,
"processedRows" : 0,
"processedBytes" : 0,
"nodes" : 0,
"queuedTimeMillis" : 1,
"elapsedTimeMillis" : 2,
"peakMemoryBytes" : 0
}
➜ ~ curl http://localhost:8081/v1/statement/20191113_033653_00006_dg6hb/2
{
"id" : "20191113_033653_00006_dg6hb",
"data" : [
[
"pulsar"
],
[
"system"
]
],
"infoUri" : "http://localhost:8081/ui/query.html?20191113_033653_00006_dg6hb",
"columns" : [
{
"typeSignature" : {
"rawType" : "varchar",
"arguments" : [
{
"kind" : "LONG_LITERAL",
"value" : 6
}
],
"literalArguments" : [],
"typeArguments" : []
},
"name" : "Catalog",
"type" : "varchar(6)"
}
],
"stats" : {
"wallTimeMillis" : 104,
"scheduled" : true,
"userTimeMillis" : 14,
"progressPercentage" : 100,
"totalSplits" : 19,
"nodes" : 1,
"cpuTimeMillis" : 16,
"queued" : false,
"queuedTimeMillis" : 1,
"state" : "FINISHED",
"peakMemoryBytes" : 0,
"elapsedTimeMillis" : 111,
"processedBytes" : 0,
"processedRows" : 0,
"rootStage" : {
"cpuTimeMillis" : 1,
"runningSplits" : 0,
"completedSplits" : 1,
"subStages" : [
{
"cpuTimeMillis" : 14,
"runningSplits" : 0,
"state" : "FINISHED",
"completedSplits" : 17,
"subStages" : [
{
"wallTimeMillis" : 7,
"subStages" : [],
"stageId" : "2",
"done" : true,
"nodes" : 1,
"totalSplits" : 1,
"processedBytes" : 22,
"processedRows" : 2,
"queuedSplits" : 0,
"userTimeMillis" : 1,
"cpuTimeMillis" : 1,
"runningSplits" : 0,
"state" : "FINISHED",
"completedSplits" : 1
}
],
"wallTimeMillis" : 92,
"nodes" : 1,
"done" : true,
"stageId" : "1",
"userTimeMillis" : 12,
"processedRows" : 2,
"processedBytes" : 51,
"queuedSplits" : 0,
"totalSplits" : 17
}
],
"wallTimeMillis" : 5,
"done" : true,
"nodes" : 1,
"stageId" : "0",
"userTimeMillis" : 1,
"processedRows" : 2,
"processedBytes" : 22,
"totalSplits" : 1,
"queuedSplits" : 0
},
"runningSplits" : 0,
"completedSplits" : 19
}