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;
|
||||
}
|
||||
else if (es->format == EXPLAIN_FORMAT_JSON)
|
||||
{
|
||||
ExplainOpenGroup("Distributed Query", NULL, true, es);
|
||||
}
|
||||
|
||||
routerExecutablePlan = RouterExecutablePlan(multiPlan, TaskExecutorType);
|
||||
|
||||
|
@ -245,6 +249,13 @@ MultiExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
|
|||
appendStringInfo(es->str, "Master Query\n");
|
||||
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);
|
||||
|
||||
|
@ -253,6 +264,11 @@ MultiExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
|
|||
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;
|
||||
int taskCount = list_length(taskList);
|
||||
|
||||
ExplainOpenGroup("Job", NULL, true, es);
|
||||
ExplainOpenGroup("Job", "Job", true, es);
|
||||
|
||||
ExplainPropertyInteger("Task Count", taskCount, es);
|
||||
|
||||
|
@ -424,7 +440,7 @@ ExplainJob(Job *job, ExplainState *es)
|
|||
ExplainCloseGroup("Tasks", "Tasks", false, es);
|
||||
}
|
||||
|
||||
ExplainCloseGroup("Job", NULL, true, es);
|
||||
ExplainCloseGroup("Job", "Job", true, es);
|
||||
|
||||
/* show explain output for depended jobs, if any */
|
||||
foreach(dependedJobCell, dependedJobList)
|
||||
|
|
|
@ -28,56 +28,59 @@ EXPLAIN (COSTS FALSE, FORMAT JSON)
|
|||
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
||||
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
||||
[
|
||||
"Executor": "Real-Time",
|
||||
{
|
||||
"Task Count": 6,
|
||||
"Tasks Shown": "One of 6",
|
||||
"Tasks": [
|
||||
{
|
||||
"Node": "host=localhost port=57637 dbname=regression",
|
||||
"Remote Plan": [
|
||||
[
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Aggregate",
|
||||
"Strategy": "Hashed",
|
||||
"Group Key": ["l_quantity"],
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Seq Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Relation Name": "lineitem_102010",
|
||||
"Alias": "lineitem"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Sort",
|
||||
"Sort Key": ["(sum(((sum(intermediate_column_41_1))::bigint)))::bigint", "intermediate_column_41_0"],
|
||||
"Plans": [
|
||||
"Executor": "Real-Time",
|
||||
"Job": {
|
||||
"Task Count": 6,
|
||||
"Tasks Shown": "One of 6",
|
||||
"Tasks": [
|
||||
{
|
||||
"Node Type": "Aggregate",
|
||||
"Strategy": "Hashed",
|
||||
"Parent Relationship": "Outer",
|
||||
"Group Key": ["intermediate_column_41_0"],
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Seq Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Relation Name": "pg_merge_job_0041",
|
||||
"Alias": "pg_merge_job_0041"
|
||||
}
|
||||
"Node": "host=localhost port=57637 dbname=regression",
|
||||
"Remote Plan": [
|
||||
[
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Aggregate",
|
||||
"Strategy": "Hashed",
|
||||
"Group Key": ["l_quantity"],
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Seq Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Relation Name": "lineitem_102010",
|
||||
"Alias": "lineitem"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"Master Query":
|
||||
{
|
||||
"Plan": {
|
||||
"Node Type": "Sort",
|
||||
"Sort Key": ["(sum(((sum(intermediate_column_41_1))::bigint)))::bigint", "intermediate_column_41_0"],
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Aggregate",
|
||||
"Strategy": "Hashed",
|
||||
"Parent Relationship": "Outer",
|
||||
"Group Key": ["intermediate_column_41_0"],
|
||||
"Plans": [
|
||||
{
|
||||
"Node Type": "Seq Scan",
|
||||
"Parent Relationship": "Outer",
|
||||
"Relation Name": "pg_merge_job_0041",
|
||||
"Alias": "pg_merge_job_0041"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -150,7 +153,8 @@ EXPLAIN (COSTS FALSE, FORMAT YAML)
|
|||
SELECT l_quantity, count(*) count_quantity FROM lineitem
|
||||
GROUP BY l_quantity ORDER BY count_quantity, l_quantity;
|
||||
Executor: "Real-Time"
|
||||
- Task Count: 6
|
||||
Job:
|
||||
Task Count: 6
|
||||
Tasks Shown: "One of 6"
|
||||
Tasks:
|
||||
- Node: "host=localhost port=57637 dbname=regression"
|
||||
|
|
Loading…
Reference in New Issue