Skip to content

Commit

Permalink
Plans: Add plan for a CTE
Browse files Browse the repository at this point in the history
  • Loading branch information
vogelsgesang committed Jan 22, 2024
1 parent d45a646 commit f1ed1ec
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plan-dumper/queries/cte.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
WITH cte AS (SELECT a1, SUM(b1), AVG(c1)
FROM t1
GROUP BY a1
)
SELECT * FROM cte UNION ALL SELECT * FROM cte
53 changes: 53 additions & 0 deletions standalone-app/examples/hyper/cte.plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"operator": "executiontarget",
"operatorId": 1,
"cardinality": 200,
"producesRows": true,
"output": [{"expression": "iuref", "iu": ["v", ["Integer"]]}, {"expression": "iuref", "iu": ["v2", ["BigInt"]]}, {"expression": "iuref", "iu": ["v3", ["Numeric", 14, 4]]}],
"outputNames": ["a1", "sum", "avg"],
"input": {
"operator": "unionall",
"operatorId": 2,
"sqlpos": [[105, 114]],
"cardinality": 200,
"input": [{
"operator": "explicitscan",
"operatorId": 3,
"sqlpos": [[101, 104]],
"cardinality": 100,
"mapping": [{"source": {"expression": "iuref", "iu": ["v4", ["Integer"]]}, "target": ["v5", ["Integer"]]}, {"source": {"expression": "iuref", "iu": ["v6", ["BigInt"]]}, "target": ["v7", ["BigInt"]]}, {"source": {"expression": "iuref", "iu": ["v8", ["Numeric", 14, 4]]}, "target": ["v9", ["Numeric", 14, 4]]}],
"input": {
"operator": "groupby",
"operatorId": 4,
"sqlpos": [[73, 84], [42, 49], [51, 58]],
"cardinality": 100,
"input": {
"operator": "tablescan",
"operatorId": 5,
"sqlpos": [[67, 69]],
"cardinality": 2000,
"relationId": 0,
"schema": {"type":"sessionschema"},
"values": [{"name": "a1", "type": ["Integer"], "iu": ["v10", ["Integer"]]}, {"name": "b1", "type": ["Integer"], "iu": ["v11", ["Integer"]]}, {"name": "c1", "type": ["Integer"], "iu": ["v12", ["Integer"]]}],
"debugName": {"classification": "nonsensitive", "value": "t1"},
"selectivity": 1
},
"keyExpressions": [{"expression": {"value": {"expression": "iuref", "iu": "v10"}}, "iu": ["v4", ["Integer"]]}],
"groupingSets": [{"keyIndices": [0], "coreIndices": [0], "behavior": "regular"}],
"emptyGroups": false,
"aggExpressions": [{"value": {"expression": "iuref", "iu": "v11"}}, {"value": {"expression": "iuref", "iu": "v12"}}],
"aggregates": [{"source": 1, "operation": {"aggregate": "avg"}, "iu": ["v8", ["Numeric", 14, 4]]}, {"source": 0, "operation": {"aggregate": "sum"}, "iu": ["v6", ["BigInt"]]}]
}
}, {
"operator": "explicitscan",
"operatorId": 6,
"sqlpos": [[129, 132]],
"cardinality": 100,
"mapping": [{"source": {"expression": "iuref", "iu": "v4"}, "target": ["v13", ["Integer"]]}, {"source": {"expression": "iuref", "iu": "v6"}, "target": ["v14", ["BigInt"]]}, {"source": {"expression": "iuref", "iu": "v8"}, "target": ["v15", ["Numeric", 14, 4]]}],
"input": 4
}],
"ius": [["v", ["Integer"]], ["v2", ["BigInt"]], ["v3", ["Numeric", 14, 4]]],
"values": [[{"expression": "iuref", "iu": "v5"}, {"expression": "iuref", "iu": "v7"}, {"expression": "iuref", "iu": "v9"}], [{"expression": "iuref", "iu": "v13"}, {"expression": "iuref", "iu": "v14"}, {"expression": "iuref", "iu": "v15"}]],
"collates": [null, null, null]
}
}
1 change: 1 addition & 0 deletions standalone-app/examples/postgres/cte.plan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"Plan": {"Node Type": "Append", "Parallel Aware": false, "Async Capable": false, "Startup Cost": 48.2, "Total Cost": 58.2, "Plan Rows": 400, "Plan Width": 44, "Subplans Removed": 0, "Plans": [{"Node Type": "Aggregate", "Strategy": "Hashed", "Partial Mode": "Simple", "Parent Relationship": "InitPlan", "Subplan Name": "CTE cte", "Parallel Aware": false, "Async Capable": false, "Startup Cost": 45.7, "Total Cost": 48.2, "Plan Rows": 200, "Plan Width": 44, "Output": ["t1.a1", "sum(t1.b1)", "avg(t1.c1)"], "Group Key": ["t1.a1"], "Planned Partitions": 0, "Plans": [{"Node Type": "Seq Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Relation Name": "t1", "Schema": "pg_temp", "Alias": "t1", "Startup Cost": 0.0, "Total Cost": 30.4, "Plan Rows": 2040, "Plan Width": 12, "Output": ["t1.a1", "t1.b1", "t1.c1"]}]}, {"Node Type": "CTE Scan", "Parent Relationship": "Member", "Parallel Aware": false, "Async Capable": false, "CTE Name": "cte", "Alias": "cte", "Startup Cost": 0.0, "Total Cost": 4.0, "Plan Rows": 200, "Plan Width": 44, "Output": ["cte.a1", "cte.sum", "cte.avg"]}, {"Node Type": "CTE Scan", "Parent Relationship": "Member", "Parallel Aware": false, "Async Capable": false, "CTE Name": "cte", "Alias": "cte_1", "Startup Cost": 0.0, "Total Cost": 4.0, "Plan Rows": 200, "Plan Width": 44, "Output": ["cte_1.a1", "cte_1.sum", "cte_1.avg"]}]}}]

0 comments on commit f1ed1ec

Please sign in to comment.