mirror of https://github.com/citusdata/citus.git
Distributed EXPLAIN: Generate valid JSON output.
This modifies the EXPLAIN output functions to actually generate valid JSON output when (FORMAT JSON) is being used. Fixes #494.pull/495/head
parent
ca909a71fc
commit
2f694f7af3
|
@ -196,6 +196,10 @@ MultiExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
|
||||||
|
|
||||||
es->indent += 1;
|
es->indent += 1;
|
||||||
}
|
}
|
||||||
|
else if (es->format == EXPLAIN_FORMAT_JSON)
|
||||||
|
{
|
||||||
|
ExplainOpenGroup("Distributed Query", NULL, true, es);
|
||||||
|
}
|
||||||
|
|
||||||
routerExecutablePlan = RouterExecutablePlan(multiPlan, TaskExecutorType);
|
routerExecutablePlan = RouterExecutablePlan(multiPlan, TaskExecutorType);
|
||||||
|
|
||||||
|
@ -245,6 +249,13 @@ MultiExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
|
||||||
appendStringInfo(es->str, "Master Query\n");
|
appendStringInfo(es->str, "Master Query\n");
|
||||||
es->indent += 1;
|
es->indent += 1;
|
||||||
}
|
}
|
||||||
|
else if (es->format == EXPLAIN_FORMAT_JSON)
|
||||||
|
{
|
||||||
|
ExplainJSONLineEnding(es);
|
||||||
|
appendStringInfoSpaces(es->str, es->indent * 2);
|
||||||
|
appendStringInfo(es->str, "\"Master Query\":");
|
||||||
|
es->grouping_stack = lcons_int(0, es->grouping_stack);
|
||||||
|
}
|
||||||
|
|
||||||
ExplainMasterPlan(masterPlan, into, es, queryString, params, &planDuration);
|
ExplainMasterPlan(masterPlan, into, es, queryString, params, &planDuration);
|
||||||
|
|
||||||
|
@ -253,6 +264,11 @@ MultiExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
|
||||||
es->indent -= 1;
|
es->indent -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (es->format == EXPLAIN_FORMAT_JSON)
|
||||||
|
{
|
||||||
|
ExplainCloseGroup("Distributed Query", NULL, true, es);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -390,7 +406,7 @@ ExplainJob(Job *job, ExplainState *es)
|
||||||
List *taskList = job->taskList;
|
List *taskList = job->taskList;
|
||||||
int taskCount = list_length(taskList);
|
int taskCount = list_length(taskList);
|
||||||
|
|
||||||
ExplainOpenGroup("Job", NULL, true, es);
|
ExplainOpenGroup("Job", "Job", true, es);
|
||||||
|
|
||||||
ExplainPropertyInteger("Task Count", taskCount, es);
|
ExplainPropertyInteger("Task Count", taskCount, es);
|
||||||
|
|
||||||
|
@ -424,7 +440,7 @@ ExplainJob(Job *job, ExplainState *es)
|
||||||
ExplainCloseGroup("Tasks", "Tasks", false, es);
|
ExplainCloseGroup("Tasks", "Tasks", false, es);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExplainCloseGroup("Job", NULL, true, es);
|
ExplainCloseGroup("Job", "Job", true, es);
|
||||||
|
|
||||||
/* show explain output for depended jobs, if any */
|
/* show explain output for depended jobs, if any */
|
||||||
foreach(dependedJobCell, dependedJobList)
|
foreach(dependedJobCell, dependedJobList)
|
||||||
|
|
|
@ -28,8 +28,9 @@ EXPLAIN (COSTS FALSE, FORMAT JSON)
|
||||||
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
||||||
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
||||||
[
|
[
|
||||||
"Executor": "Real-Time",
|
|
||||||
{
|
{
|
||||||
|
"Executor": "Real-Time",
|
||||||
|
"Job": {
|
||||||
"Task Count": 6,
|
"Task Count": 6,
|
||||||
"Tasks Shown": "One of 6",
|
"Tasks Shown": "One of 6",
|
||||||
"Tasks": [
|
"Tasks": [
|
||||||
|
@ -58,6 +59,7 @@ EXPLAIN (COSTS FALSE, FORMAT JSON)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Master Query":
|
||||||
{
|
{
|
||||||
"Plan": {
|
"Plan": {
|
||||||
"Node Type": "Sort",
|
"Node Type": "Sort",
|
||||||
|
@ -80,6 +82,7 @@ EXPLAIN (COSTS FALSE, FORMAT JSON)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
-- Test XML format
|
-- Test XML format
|
||||||
EXPLAIN (COSTS FALSE, FORMAT XML)
|
EXPLAIN (COSTS FALSE, FORMAT XML)
|
||||||
|
@ -150,7 +153,8 @@ EXPLAIN (COSTS FALSE, FORMAT YAML)
|
||||||
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
||||||
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
||||||
Executor: "Real-Time"
|
Executor: "Real-Time"
|
||||||
- Task Count: 6
|
Job:
|
||||||
|
Task Count: 6
|
||||||
Tasks Shown: "One of 6"
|
Tasks Shown: "One of 6"
|
||||||
Tasks:
|
Tasks:
|
||||||
- Node: "host=localhost port=57637 dbname=regression"
|
- Node: "host=localhost port=57637 dbname=regression"
|
||||||
|
|
Loading…
Reference in New Issue