Repository navigation
Expand SQL plan coverage #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7baf60d
Expand SQL plan coverage and refresh database plan dumps
vogelsgesang 91b7574
Clarify optional edge coverage in PGQ fixture
vogelsgesang 2e3da9c
Revert noisy Hyper cahnges
vogelsgesang ecc23b5
Align DML mode documentation
vogelsgesang 743d57d
Update loader snapshots for reverted Hyper plans
vogelsgesang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,27 @@ | ||
| WITH cte AS (SELECT l_orderkey, SUM(l_quantity), AVG(l_extendedprice) | ||
| FROM lineitem | ||
| GROUP BY l_orderkey | ||
| WITH base AS ( | ||
| SELECT l_orderkey, l_partkey, l_quantity, l_extendedprice | ||
| FROM lineitem | ||
| ), filtered AS ( | ||
| SELECT * | ||
| FROM base | ||
| WHERE l_quantity > 1 | ||
| ), grouped AS ( | ||
| SELECT l_orderkey, SUM(l_quantity) AS quantity, AVG(l_extendedprice) AS price | ||
| FROM filtered | ||
| GROUP BY l_orderkey | ||
| ), nested AS ( | ||
| WITH nested_filtered AS ( | ||
| SELECT l_orderkey, quantity | ||
| FROM grouped | ||
| WHERE quantity > 10 | ||
| ) | ||
| SELECT l_orderkey, quantity | ||
| FROM nested_filtered | ||
| ), reused AS ( | ||
| SELECT l_orderkey, quantity FROM nested | ||
| UNION ALL | ||
| SELECT l_orderkey, quantity FROM nested | ||
| ) | ||
| SELECT * FROM cte UNION ALL SELECT * FROM cte | ||
| SELECT r.l_orderkey, r.quantity, g.price | ||
| FROM reused r | ||
| JOIN grouped g ON g.l_orderkey = r.l_orderkey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- DML queries are intentionally limited to simple mode because ANALYZE | ||
| --- executes the mutation and would change the shared setup state. | ||
| --- UNSUPPORTED: mariadb | ||
| --- MariaDB supports DELETE ... USING, but does not allow RETURNING on | ||
| --- multi-table DELETE statements. | ||
| --- MODES: simple | ||
| DELETE FROM t2 | ||
| USING t1 | ||
| WHERE t2.a2 = t1.a1 | ||
| RETURNING t2.a2, t2.b2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- DML queries are intentionally limited to simple mode because ANALYZE | ||
| --- executes the mutation and would change the shared setup state. | ||
| --- MODES: simple | ||
|
vogelsgesang marked this conversation as resolved.
Outdated
|
||
| DELETE FROM t2 | ||
| WHERE a2 < 10 | ||
| RETURNING a2, b2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- DML queries are intentionally limited to simple mode because ANALYZE | ||
| --- executes the mutation and would change the shared setup state. | ||
| --- MODES: simple | ||
| INSERT INTO t2 (a2, b2, c2) | ||
| SELECT a1, b1, c1 | ||
| FROM t1 | ||
| RETURNING a2, b2, c2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- DML queries are intentionally limited to simple mode because ANALYZE | ||
| --- executes the mutation and would change the shared setup state. | ||
| --- UNSUPPORTED: mariadb | ||
| --- MariaDB does not support PostgreSQL's UPDATE ... FROM syntax. | ||
| --- MODES: simple | ||
| UPDATE t2 | ||
| SET a2 = t1.a1 + 1, | ||
| b2 = t1.b1 | ||
| FROM t1 | ||
| WHERE t2.a2 = t1.a1 | ||
| RETURNING t2.a2, t2.b2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- DML queries are intentionally limited to simple mode because ANALYZE | ||
| --- executes the mutation and would change the shared setup state. | ||
| --- MODES: simple | ||
| UPDATE t2 | ||
| SET a2 = a2 + 1, | ||
| b2 = b2 + 1 | ||
| WHERE a2 < 10 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- UNSUPPORTED: postgres, duckdb, umbra, cedardb, mariadb | ||
| --- SQL/PGQ is currently only available in Hyper. | ||
| --- Simple mode is sufficient here because the fixture targets PGQ's | ||
| --- relational lowering and does not need runtime measurements. | ||
| --- MODES: simple, steps | ||
|
|
||
| -- Exercise a questioned edge and ONE ROW PER STEP on the TPC-H part/supplier | ||
|
vogelsgesang marked this conversation as resolved.
Outdated
|
||
| -- relationship. The optional edge also gives the sqlpos implementation a | ||
| -- concrete absent-edge branch to annotate. | ||
| WITH pg AS PROPERTY GRAPH ( | ||
| VERTEX TABLES ( | ||
| part KEY (p_partkey) | ||
| LABEL Product | ||
| PROPERTIES (part.p_name AS name), | ||
| supplier KEY (s_suppkey) | ||
| LABEL Supplier | ||
| PROPERTIES (supplier.s_name AS name) | ||
| ) | ||
| EDGE TABLES ( | ||
| partsupp KEY (ps_partkey, ps_suppkey) | ||
| SOURCE KEY (ps_partkey) REFERENCES part | ||
| DESTINATION KEY (ps_suppkey) REFERENCES supplier | ||
| LABEL Supply | ||
| PROPERTIES (partsupp.ps_supplycost AS supply_cost) | ||
| ) | ||
| ) | ||
| SELECT * | ||
| FROM GRAPH_TABLE(pg | ||
| MATCH (product:Product)-[supply:Supply]->?(vendor:Supplier) | ||
| ONE ROW PER STEP (source_step, edge_step, destination_step) | ||
| COLUMNS ( | ||
| source_step.name AS product_name, | ||
| edge_step.supply_cost AS supply_cost, | ||
| destination_step.name AS supplier_name | ||
| ) | ||
| ) AS matched | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- UNSUPPORTED: postgres, duckdb, umbra, cedardb, mariadb | ||
| --- SQL/PGQ is currently only available in Hyper. | ||
| --- Simple mode is sufficient here because the fixture targets PGQ's | ||
| --- relational lowering and does not need runtime measurements. | ||
| --- MODES: simple, steps | ||
|
|
||
| -- Match parts to their suppliers, using labels and projected properties from | ||
| -- the shared TPC-H schema. | ||
| WITH pg AS PROPERTY GRAPH ( | ||
| VERTEX TABLES ( | ||
| part KEY (p_partkey) | ||
| LABEL Product | ||
| PROPERTIES (part.p_name AS name, part.p_brand AS brand), | ||
| supplier KEY (s_suppkey) | ||
| LABEL Supplier | ||
| PROPERTIES (supplier.s_name AS name, supplier.s_acctbal AS account_balance) | ||
| ) | ||
| EDGE TABLES ( | ||
| partsupp KEY (ps_partkey, ps_suppkey) | ||
| SOURCE KEY (ps_partkey) REFERENCES part | ||
| DESTINATION KEY (ps_suppkey) REFERENCES supplier | ||
| LABEL Supply | ||
| PROPERTIES (partsupp.ps_supplycost AS supply_cost) | ||
| ) | ||
| ) | ||
| SELECT * | ||
| FROM GRAPH_TABLE(pg | ||
| MATCH ( | ||
| product:Product WHERE product.brand = 'Brand#11' | ||
| )-[ | ||
| supply:Supply WHERE supply.supply_cost > 100 | ||
| ]->( | ||
| vendor:Supplier WHERE vendor.account_balance > 0 | ||
| ) | ||
| WHERE product.name LIKE '%blue%' | ||
| COLUMNS ( | ||
| product.name AS product_name, | ||
| supply.supply_cost AS supply_cost, | ||
| vendor.name AS supplier_name | ||
| ) | ||
| ) AS matched |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,56 @@ | ||
| SELECT l_orderkey, l_partkey FROM lineitem | ||
| UNION ALL | ||
| SELECT l_orderkey, l_suppkey FROM lineitem | ||
| UNION ALL | ||
| ( | ||
| SELECT l_suppkey, l_partkey FROM lineitem | ||
| WHERE l_quantity < 25 | ||
| INTERSECT ALL | ||
| SELECT l_suppkey, l_partkey FROM lineitem | ||
| WHERE l_quantity >= 25 | ||
| EXCEPT ALL | ||
| SELECT l_suppkey, l_partkey FROM lineitem | ||
| WHERE l_quantity >= 25 | ||
| ) | ||
| -- Exercise every set-operation variant, including n-ary and nested trees. | ||
| -- Keeping the arms independent gives optimizers an opportunity to flatten the | ||
| -- UNION/INTERSECT/EXCEPT chains into n-ary operators. | ||
| SELECT 'union' AS operation, value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 WHERE a1 < 10 | ||
| UNION | ||
| SELECT b1 FROM t1 WHERE b1 < 10 | ||
| UNION | ||
| SELECT c1 FROM t1 WHERE c1 < 10 | ||
| ) u | ||
| UNION ALL | ||
| SELECT 'union-all', value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 WHERE a1 >= 10 | ||
| UNION ALL | ||
| SELECT b1 FROM t1 WHERE b1 >= 10 | ||
| UNION ALL | ||
| SELECT c1 FROM t1 WHERE c1 >= 10 | ||
| ) ua | ||
| UNION ALL | ||
| SELECT 'intersect', value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 | ||
| INTERSECT | ||
| SELECT b1 FROM t1 | ||
| INTERSECT | ||
| SELECT c1 FROM t1 | ||
| ) i | ||
| UNION ALL | ||
| SELECT 'intersect-all', value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 | ||
| INTERSECT ALL | ||
| SELECT b1 FROM t1 | ||
| INTERSECT ALL | ||
| SELECT c1 FROM t1 | ||
| ) ia | ||
| UNION ALL | ||
| SELECT 'except', value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 | ||
| EXCEPT | ||
| SELECT b1 FROM t1 | ||
| EXCEPT | ||
| SELECT c1 FROM t1 | ||
| ) e | ||
| UNION ALL | ||
| SELECT 'except-all', value | ||
| FROM ( | ||
| SELECT a1 AS value FROM t1 | ||
| EXCEPT ALL | ||
| SELECT b1 FROM t1 | ||
| EXCEPT ALL | ||
| SELECT c1 FROM t1 | ||
| ) ea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- A correlated scalar subquery is lowered to a single join on Hyper. The | ||
| -- correlation makes the inner query depend on the current outer row. | ||
| SELECT t1.a1, | ||
| (SELECT t2.b2 FROM t2 WHERE t2.a2 = t1.a1) AS matching_b | ||
| FROM t1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- For this query, the engine must ensure that the subquery returns at most | ||
| -- one row. The optimizer cannot prove this, so that assertion must be | ||
| -- preserved in the query plan somehow. | ||
| SELECT t1.a1, | ||
| (SELECT t2.b2 FROM t2) AS matching_b | ||
| FROM t1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- UNSUPPORTED: umbra, cedardb, mariadb | ||
| --- Umbra, CedarDB, and MariaDB do not implement TABLESAMPLE SYSTEM or BERNOULLI. | ||
| SELECT a1, b1, c1 | ||
| FROM t1 TABLESAMPLE SYSTEM (50) | ||
| REPEATABLE (1) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.