Repository navigation
Fix accessing an inherited property through subcollection #580
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 all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
80a98a6
adding bug test
john-sanchez31 4eb8bc9
merging main, solving conflicts
john-sanchez31 0443d8f
wip: preparing solution
john-sanchez31 d64a79d
adding extra error handling for mock server setup
john-sanchez31 6ee0ac6
adding fix for accessed term incorrectly through a child collection […
john-sanchez31 6180ecd
fixing test
john-sanchez31 c499e0e
merge conflicts [run ci][run all]
john-sanchez31 f8c5529
fixing shadowed test[run ci][run all]
john-sanchez31 fec0f66
deleting breakpoint [run ci][run all]
john-sanchez31 cf35683
updating error message test [run ci][run all]
john-sanchez31 bd9cec3
deleting breakpoint [run ci][run all]
john-sanchez31 959483d
fixing bodosql and pyiceberg version [run ci][run all]
john-sanchez31 7ff3ccd
reversing bodo version related changes [run ci][run all]
john-sanchez31 91c534a
adding fix for server tests setup and new test [run ci][run all]
john-sanchez31 0e5c054
Merge branch 'main' into John/fix_access_calc
john-sanchez31 4f70f32
changing names_defined_in_child_chain implementation [run ci][run all]
john-sanchez31 4945d50
fixing implementation with qdag [run ci][run all]
john-sanchez31 f2b0b94
fixing merging conflicts [run ci][run all]
john-sanchez31 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
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ROOT(columns=[('rkey', r_regionkey), ('region_name', max_r_name), ('n_nations', n_rows)], orderings=[(r_regionkey):asc_first]) | ||
| AGGREGATE(keys={'r_regionkey': r_regionkey}, aggregations={'max_r_name': MAX(r_name), 'n_rows': COUNT()}) | ||
| JOIN(condition=t0.r_regionkey == t1.n_regionkey, type=INNER, cardinality=PLURAL_FILTER, reverse_cardinality=PLURAL_FILTER, columns={'r_name': t0.r_name, 'r_regionkey': t0.r_regionkey}) | ||
| SCAN(table=tpch.REGION, columns={'r_name': r_name, 'r_regionkey': r_regionkey}) | ||
| SCAN(table=tpch.NATION, columns={'n_regionkey': n_regionkey}) |
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 @@ | ||
| ROOT(columns=[('key', o_orderkey), ('x', max_c_phone)], orderings=[(o_orderkey):asc_first], limit=5:numeric) | ||
| JOIN(condition=t0.o_custkey == t1.c_custkey, type=LEFT, cardinality=SINGULAR_FILTER, reverse_cardinality=PLURAL_FILTER, columns={'max_c_phone': t1.max_c_phone, 'o_orderkey': t0.o_orderkey}) | ||
| SCAN(table=tpch.ORDERS, columns={'o_custkey': o_custkey, 'o_orderkey': o_orderkey}) | ||
| AGGREGATE(keys={'c_custkey': c_custkey}, aggregations={'max_c_phone': MAX(c_phone)}) | ||
| JOIN(condition=t0.c_custkey == t1.o_custkey, type=INNER, cardinality=PLURAL_FILTER, reverse_cardinality=SINGULAR_ACCESS, columns={'c_custkey': t0.c_custkey, 'c_phone': t0.c_phone}) | ||
| SCAN(table=tpch.CUSTOMER, columns={'c_custkey': c_custkey, 'c_phone': c_phone}) | ||
| SCAN(table=tpch.ORDERS, columns={'o_custkey': o_custkey}) |
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 |
|---|---|---|
|
|
@@ -3967,6 +3967,63 @@ def partition_key_name_collision(): | |
| ) | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add another test for PARTITION-child with e.g. something like the |
||
| def parent_calc_access_error(): | ||
| """ | ||
| Test that a child collection's CALCULATE cannot reference a term | ||
| defined in a parent collection's CALCULATE, and that doing so raises a | ||
| descriptive error message instead of silently qualifying and producing an | ||
| error later. | ||
| """ | ||
| # 'top' calculates 'cust_name' on customers | ||
| top = customers.CALCULATE(cust_name=name) | ||
|
|
||
| # Referencing 'customer.cust_name' from orders causes a lowering error | ||
| result = top.orders.CALCULATE( | ||
| correct_usage=cust_name, incorrect_usage=customer.cust_name | ||
| ) | ||
| return result | ||
|
|
||
|
|
||
| def shadowed_calc_term(): | ||
| """ | ||
| The child `customer.CALCULATE(cust_name=phone).orders` redefines `cust_name` | ||
| as `phone`, and `.orders.cust_name` then reads it. Within that child, the nearest | ||
| definition is the inner one, so the value really comes from the child's own | ||
| data. | ||
| """ | ||
| return ( | ||
| customers.CALCULATE(cust_name=name) | ||
| .orders.CALCULATE( | ||
| key, | ||
| x=MAX(customer.CALCULATE(cust_name=phone).orders.cust_name), | ||
| ) | ||
| .TOP_K(5, by=key.ASC()) | ||
| ) | ||
|
|
||
|
|
||
| def partition_child_inherited_term(): | ||
| """ | ||
| Pair every region with its nations via CROSS, partition the pairs by | ||
| region, and aggregate a term (`region_name`) that was down-streamed from | ||
| the regions CALCULATE *inside the partitioned data*. The PARTITION | ||
| context only exposes `rkey`, so accessing `nations.region_name` through | ||
| the partition child is valid (context_inherits is False). | ||
| """ | ||
|
|
||
| return ( | ||
| regions.CALCULATE(rkey=key, region_name=name) | ||
| .CROSS(nations) | ||
| .WHERE(region_key == rkey) | ||
| .PARTITION(name="region_groups", by=rkey) | ||
| .CALCULATE( | ||
| rkey, | ||
| region_name=MAX(nations.region_name), | ||
| n_nations=COUNT(nations), | ||
| ) | ||
| .ORDER_BY(rkey.ASC()) | ||
| ) | ||
|
|
||
|
|
||
| def chained_partition_transformed_key(): | ||
| """ | ||
| Test for fixing the problem with chaining a second PARTITION on top of a | ||
|
|
||
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_ansi.sql
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 @@ | ||
| SELECT | ||
| region.r_regionkey AS rkey, | ||
| MAX(region.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.region AS region | ||
| JOIN tpch.nation AS nation | ||
| ON nation.n_regionkey = region.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_databricks.sql
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 @@ | ||
| SELECT | ||
| region.r_regionkey AS rkey, | ||
| MAX(region.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.region AS region | ||
| JOIN tpch.nation AS nation | ||
| ON nation.n_regionkey = region.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_duckdb.sql
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 @@ | ||
| SELECT | ||
| region.r_regionkey AS rkey, | ||
| MAX(region.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.region AS region | ||
| JOIN tpch.nation AS nation | ||
| ON nation.n_regionkey = region.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 NULLS FIRST |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_mysql.sql
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 @@ | ||
| SELECT | ||
| REGION.r_regionkey AS rkey, | ||
| MAX(REGION.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.REGION AS REGION | ||
| JOIN tpch.NATION AS NATION | ||
| ON NATION.n_regionkey = REGION.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_oracle.sql
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 @@ | ||
| SELECT | ||
| REGION.r_regionkey AS rkey, | ||
| MAX(REGION.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM TPCH.REGION REGION | ||
| JOIN TPCH.NATION NATION | ||
| ON NATION.n_regionkey = REGION.r_regionkey | ||
| GROUP BY | ||
| REGION.r_regionkey | ||
| ORDER BY | ||
| 1 NULLS FIRST |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_postgres.sql
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 @@ | ||
| SELECT | ||
| region.r_regionkey AS rkey, | ||
| MAX(region.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.region AS region | ||
| JOIN tpch.nation AS nation | ||
| ON nation.n_regionkey = region.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 NULLS FIRST |
11 changes: 11 additions & 0 deletions
11
tests/test_sql_refsols/partition_child_inherited_term_snowflake.sql
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 @@ | ||
| SELECT | ||
| region.r_regionkey AS rkey, | ||
| MAX(region.r_name) AS region_name, | ||
| COUNT(*) AS n_nations | ||
| FROM tpch.region AS region | ||
| JOIN tpch.nation AS nation | ||
| ON nation.n_regionkey = region.r_regionkey | ||
| GROUP BY | ||
| 1 | ||
| ORDER BY | ||
| 1 NULLS FIRST |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated changes to the mock server setup error handling. I was already using port 8000 but didn't get the correct error message