Skip to content
Merged
Show file tree
Hide file tree
Changes from 177 commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
9ac45d2
moving error classes/utilities to common module
knassre-bodo Jul 8, 2025
8728487
Changed more errors to be PyDough exceptions
knassre-bodo Jul 8, 2025
675421c
Added error builder class and integrated for term not found errors
knassre-bodo Jul 8, 2025
097b8a0
Minor refactor to term_not_found error usage [RUN CI]
knassre-bodo Jul 8, 2025
18ba964
WIP
knassre-bodo Jul 9, 2025
684b5d7
WIP improvements on projection pullup
knassre-bodo Jul 9, 2025
cc004ec
Fixing filter/join cases
knassre-bodo Jul 9, 2025
de7d4e6
Bugfixes, testing for correctness [RUN CI]
knassre-bodo Jul 9, 2025
e6dea43
Merge branch 'main' into kian/projection_pullup
knassre-bodo Jul 11, 2025
3827276
Finished dealing with JOIN pull-up
knassre-bodo Jul 12, 2025
1fff8ea
Fixed pullup bugs
knassre-bodo Jul 13, 2025
07136d2
Pullup with LIMIT [RUN CI]
knassre-bodo Jul 13, 2025
922d356
Resolving conflicts
knassre-bodo Jul 13, 2025
a678974
Resolving conflicts
knassre-bodo Jul 13, 2025
602f292
Merge branch 'main' into kian/projection_pullup
knassre-bodo Jul 13, 2025
d7ec696
Adding extra round of bubbling
knassre-bodo Jul 13, 2025
d88cdb5
Compressing limit into root
knassre-bodo Jul 13, 2025
665a9dd
Restoring filter modifications
knassre-bodo Jul 13, 2025
d1fe25b
Started aggregation project pullup
knassre-bodo Jul 13, 2025
0892581
Added SUM(1)->COUNT() optimization
knassre-bodo Jul 13, 2025
a69d764
Cleanup merge projects
knassre-bodo Jul 14, 2025
13d9844
Added some adjacent aggregaiton merging
knassre-bodo Jul 14, 2025
c497127
Added min/min, max/max, anything/anything cases
knassre-bodo Jul 14, 2025
f74fc5c
Adding more aggregation simplification and comments
knassre-bodo Jul 15, 2025
d260428
Added more aggregation simplification + tests
knassre-bodo Jul 15, 2025
856e1a9
Adjusting parameters of optimization
knassre-bodo Jul 15, 2025
c4298cb
Pulled out common logic from filter/join/limit and added comments
knassre-bodo Jul 16, 2025
5e9f09d
Added remaining comments
knassre-bodo Jul 16, 2025
c45b4f2
[RUN CI]
knassre-bodo Jul 16, 2025
6a7bc49
Resolving conflicts [RUN CI]
knassre-bodo Jul 16, 2025
416fbad
Added PageRank tests and fixed bugs found along the way
knassre-bodo Jul 16, 2025
b121c31
Started adding comments
knassre-bodo Jul 16, 2025
05f7147
Started adding comments
knassre-bodo Jul 16, 2025
2697b10
Added comments
knassre-bodo Jul 16, 2025
94726ff
Fixing c4 test and refactoring the PageRank impl to be simpler & more…
knassre-bodo Jul 16, 2025
e21cf57
Merge branch 'main' into kian/projection_pullup
knassre-bodo Jul 16, 2025
44fdd33
[RUN CI]
knassre-bodo Jul 16, 2025
a53500d
Merge branch 'main' into kian/pagerank
knassre-bodo Jul 16, 2025
b5d90f2
[RUN CI]
knassre-bodo Jul 16, 2025
0128758
Added tests e/f, deleted relational/sql tests for graphs other than a/c
knassre-bodo Jul 17, 2025
c9a5fe1
Adjusted how the skips are handled
knassre-bodo Jul 17, 2025
d6ed6c6
Adding larger graph & dense graph tests [RUN CI]
knassre-bodo Jul 17, 2025
ebf5339
Changing test h to be a higher number of iterations [RUN CI]
knassre-bodo Jul 17, 2025
19d8fe5
Merge branch 'main' into kian/error_handler
knassre-bodo Jul 17, 2025
80a9ca0
Moved around more errors, got rid of redundant ones, and fixed a cros…
knassre-bodo Jul 18, 2025
e812143
Overhaul test_qualify_error
knassre-bodo Jul 18, 2025
993553f
Moving more errors
knassre-bodo Jul 18, 2025
85e7c8f
Minor adjustment to how pagerank was written
knassre-bodo Jul 18, 2025
0508822
Initial revisions
knassre-bodo Jul 18, 2025
f59f457
Added set up for simplification
knassre-bodo Jul 18, 2025
b34f6ca
Added first simplification rules
knassre-bodo Jul 19, 2025
7884341
Improved null handling for aggregations
knassre-bodo Jul 19, 2025
b281c8a
Added more simplification rules
knassre-bodo Jul 19, 2025
78f6e78
More >0 filter improvements
knassre-bodo Jul 19, 2025
e8a54b8
Added IFF and KEEP_IF rules
knassre-bodo Jul 19, 2025
40805f7
Resolving conflicts with base branch [RUN CI]
knassre-bodo Jul 19, 2025
6121806
resolving conflicts with base branch
knassre-bodo Jul 19, 2025
b8a7f77
Added more simplification patterns and tests
knassre-bodo Jul 21, 2025
bc5f383
Minor refactoring
knassre-bodo Jul 21, 2025
a828aa9
Fixing double-TPCH error handling
knassre-bodo Jul 21, 2025
2914f9b
overhauling some of the function call creation and error handling
knassre-bodo Jul 21, 2025
9f0961d
Moved function mismatch errors to use min edit distance
knassre-bodo Jul 21, 2025
2e30300
Adjusting tuning of min edit distance errors
knassre-bodo Jul 21, 2025
75c3b7c
Messing with function handling, VARIANCE name, error tuning
knassre-bodo Jul 21, 2025
b94e76d
WIP
knassre-bodo Jul 21, 2025
58cb511
Conflict WIP
knassre-bodo Jul 21, 2025
7347536
Merge branch 'kian/simplify' into kian/error_handler
knassre-bodo Jul 21, 2025
19a0fb8
Resolving conflicts and fixing UDF tests
knassre-bodo Jul 21, 2025
bf69fe8
Moved window errors
knassre-bodo Jul 21, 2025
c5fdfef
Updating helper [RUN CI]
knassre-bodo Jul 21, 2025
716782f
Merge branch 'kian/projection_pullup' into kian/pagerank
knassre-bodo Jul 21, 2025
60be207
[RUN CI]
knassre-bodo Jul 21, 2025
689a4b0
[RUN CI]
knassre-bodo Jul 21, 2025
7dced8e
Merge branch 'kian/simplify' into kian/error_handler
knassre-bodo Jul 21, 2025
ade8f35
Adding more simplification patterns and tests
knassre-bodo Jul 21, 2025
3d9167e
[RUN CI]
knassre-bodo Jul 21, 2025
3d17cad
Update pydough/conversion/projection_pullup.py
knassre-bodo Jul 22, 2025
df2e401
Final revisions/documentation [RUN CI]
knassre-bodo Jul 22, 2025
e1ae265
Resolving conflicts
knassre-bodo Jul 22, 2025
6f27a23
Resolving conflicts [RUN CI]
knassre-bodo Jul 22, 2025
2bbf925
Resolving conflicts before parent merged into main
knassre-bodo Jul 22, 2025
1005fde
Resolving conflicts [RUN cI]
knassre-bodo Jul 22, 2025
d8b2fa8
Merge branch 'kian/simplify' into kian/error_handler
knassre-bodo Jul 22, 2025
ce7e035
Completed refactor of how simplification predicates work to use a Pre…
knassre-bodo Jul 23, 2025
e6c9fbe
Refactoring to use shuttles & visitors for simplification
knassre-bodo Jul 23, 2025
94375ce
Fixing comments
knassre-bodo Jul 23, 2025
4914784
[RUN CI]
knassre-bodo Jul 23, 2025
8f0fbd3
Merge branch 'main' into kian/simplify
knassre-bodo Jul 24, 2025
f150cd5
Adding docstrings
knassre-bodo Jul 24, 2025
8d0fc6b
Revisions
knassre-bodo Jul 24, 2025
22a94ab
Stack cleanup
knassre-bodo Jul 24, 2025
a971676
Adding additional shuttle framework
knassre-bodo Jul 24, 2025
9c6caa2
[RUN CI]
knassre-bodo Jul 24, 2025
ffb58b3
Merge branch 'kian/simplify' into kian/error_handler
knassre-bodo Jul 24, 2025
95e59d1
[RUN CI]
knassre-bodo Jul 24, 2025
604a7a6
Merge branch 'main' into kian/simplify
knassre-bodo Jul 25, 2025
b63c5d4
Added more simplfication patterns to tests
knassre-bodo Jul 31, 2025
02c24bd
Revisions
knassre-bodo Jul 31, 2025
2c65773
Apply suggestions from code review
knassre-bodo Jul 31, 2025
cc12363
edit
knassre-bodo Jul 31, 2025
5f19dcd
Merge remote-tracking branch 'origin/kian/simplify' into kian/simplify
knassre-bodo Jul 31, 2025
6ec13f1
[RUN CI]
knassre-bodo Aug 1, 2025
9344c9a
Fixing SQL test [RUN CI]
knassre-bodo Aug 1, 2025
0e7f48e
Resolving conflicts
knassre-bodo Aug 1, 2025
75ee111
Merge branch 'main' into kian/error_handler
knassre-bodo Aug 1, 2025
59850bd
[RUN CI]
knassre-bodo Aug 1, 2025
5ab03d7
Merge branch 'main' into kian/error_handler
knassre-bodo Aug 1, 2025
f460cda
Revision
knassre-bodo Aug 1, 2025
315993d
Merge branch 'main' into kian/error_handler
knassre-bodo Aug 7, 2025
0fa39c7
Removing dead comment
knassre-bodo Aug 7, 2025
4247700
Resolving conflicts
knassre-bodo Aug 13, 2025
b27b96f
Resolving merge conflicts [RUN CI]
knassre-bodo Aug 14, 2025
4d899b8
Adding more comments/docstrings
knassre-bodo Aug 18, 2025
e8fd112
Initial implementation buggy WIP
knassre-bodo Aug 18, 2025
7587597
resolving conflicts [RUN CI]
knassre-bodo Aug 20, 2025
484decf
Merge branch 'kian/error_handler' into kian/join_aggregate_transpose
knassre-bodo Aug 20, 2025
7bf3268
WIP fixing column handling triple_partition + other bugs
knassre-bodo Aug 21, 2025
cb96cdb
Resolving conflicts [RUN CI]
knassre-bodo Aug 21, 2025
63682a4
WIP
knassre-bodo Aug 21, 2025
a34ec87
Adding reverse cardinality support
knassre-bodo Aug 25, 2025
65697e8
Added reverse cardinality based column pruning [RUN CI] [RUN MYSQL]
knassre-bodo Aug 25, 2025
8f7fbbe
Fixing bug [RUN CI]
knassre-bodo Aug 25, 2025
d797c43
Adjusting aggregation splitting to account for reverse cardinality [R…
knassre-bodo Aug 26, 2025
3041ac9
Stop printing cardinalities in plan files for semi/anti joins
knassre-bodo Aug 26, 2025
efa1335
Revisions and documentation [RUN CI] [RUN MYSQL]
knassre-bodo Aug 26, 2025
48e5d3d
Resolving conflicts
knassre-bodo Sep 8, 2025
b4e3318
Minor revisions
knassre-bodo Sep 8, 2025
091a353
Adjusting edge case for correlation extraction affecting cardinality
knassre-bodo Sep 10, 2025
29dd27d
Resolving conficts
knassre-bodo Sep 17, 2025
6d4e268
Resolving conflicts
knassre-bodo Sep 17, 2025
d903c9d
temporary reversion as setup is being adjusted
knassre-bodo Sep 17, 2025
f130bc3
WIP
knassre-bodo Sep 18, 2025
57bb56e
Resolving conflicts
knassre-bodo Oct 6, 2025
401c1bc
Resolving conflicts
knassre-bodo Oct 6, 2025
e148c2e
Resolving conflicts
knassre-bodo Oct 17, 2025
b987f30
Resolving conflicts
knassre-bodo Oct 17, 2025
d674b0d
Adjusting reverse cardinality edge case
knassre-bodo Oct 17, 2025
4206914
WIP transpose logic
knassre-bodo Oct 17, 2025
2d22b2a
Fixing key rename bug
knassre-bodo Oct 17, 2025
a9ac04c
Need to fix multi partition access
knassre-bodo Oct 17, 2025
a5c6160
WIP revision phase
knassre-bodo Oct 18, 2025
4ad8255
Fixing join bug
knassre-bodo Oct 18, 2025
ee93d51
Adding back the join key switch
knassre-bodo Oct 18, 2025
bd036f7
Removing plural case due to logical flaw
knassre-bodo Oct 18, 2025
7d8ac06
[RUN CI]
knassre-bodo Oct 18, 2025
036230a
Patch to make common_prefix_al faster due to sqlite issues [RUN CI]
knassre-bodo Oct 18, 2025
712d045
Minor updates to the defog graph
knassre-bodo Oct 18, 2025
1b43fbd
Adding start of the LEFT case, minus COUNT(*)
knassre-bodo Oct 20, 2025
88e74b2
Adding COUNT(*) left case, WIP
knassre-bodo Oct 20, 2025
473cc24
Identified bug in left join case: need to aggregate on LHS key
knassre-bodo Oct 21, 2025
ff71831
Revision to left case handling [RUN CI]
knassre-bodo Oct 21, 2025
def9109
Changing dealership adv3
knassre-bodo Oct 22, 2025
3274831
Merge branch 'main' into kian/join_aggregate_transpose
knassre-bodo Oct 22, 2025
0bae74c
Updating academia tests
knassre-bodo Oct 22, 2025
b7fa6e4
Updating left join merge rule
knassre-bodo Oct 22, 2025
6a11435
Fixing bug with the COUNT left case
knassre-bodo Oct 22, 2025
8991a3e
Teeing up CASE -> NULLIF rewrite
knassre-bodo Oct 22, 2025
eb17fe6
Coalesce nullif rewrite WIP
knassre-bodo Oct 22, 2025
cbc5408
Updating plans, still need to fix common_prefix_y
knassre-bodo Oct 22, 2025
f7091d8
Fixing common_prefix_y [RUN CI]
knassre-bodo Oct 22, 2025
2da07fe
Additional revisions and comments [RUN CI]
knassre-bodo Oct 23, 2025
0842267
Rewriting SUM(NULLIF(x, 0)) to SUM(x) [RUN CI]
knassre-bodo Oct 23, 2025
115a926
Adding pullup before re-doing aggregation removal [RUN CI]
knassre-bodo Oct 23, 2025
1d24b15
[RUN CI]
knassre-bodo Oct 23, 2025
11e6006
Merge branch 'main' into kian/join_aggregate_transpose
knassre-bodo Oct 26, 2025
0f9f098
Initial commit: tested prototype implementation to optimize queries v…
knassre-bodo Oct 30, 2025
fd026b2
Moving around usage location of join key substitution
knassre-bodo Oct 30, 2025
d91d799
Adding subset enhancement, and more tests of edge cases
knassre-bodo Oct 31, 2025
6b4313f
Updating plan files
knassre-bodo Oct 31, 2025
d439434
Moved around join key substitution invocation
knassre-bodo Oct 31, 2025
844eb3d
WIP singular/reverse revisions
knassre-bodo Nov 1, 2025
a13bb6a
Fixing bug with the substitution going right-to-left
knassre-bodo Nov 3, 2025
84264cc
[RUN CI]
knassre-bodo Nov 3, 2025
0a65503
Removing dead file
knassre-bodo Nov 3, 2025
7bbc1f3
Merge branch 'main' into kian/join_aggregate_transpose
knassre-bodo Nov 7, 2025
27696b8
Merge branch 'kian/join_aggregate_transpose' into kian/join_key_subst…
knassre-bodo Nov 7, 2025
2cdf361
[RUN CI]
knassre-bodo Nov 7, 2025
34d6abb
Merge branch 'main' into kian/join_aggregate_transpose
knassre-bodo Nov 24, 2025
9133bcb
Simplification revisions [RUN CI]
knassre-bodo Nov 24, 2025
4964df7
Resolving conflicts
knassre-bodo Nov 24, 2025
f9c07fe
Resolving conflicts
knassre-bodo Nov 24, 2025
586d7e0
adding comments
knassre-bodo Nov 26, 2025
25f5904
Update pydough/conversion/join_key_substitution.py
knassre-bodo Nov 26, 2025
b86c5dc
[RUN CI]
knassre-bodo Nov 26, 2025
1bca6af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2025
07e6ab8
[RUN CI]
knassre-bodo Nov 26, 2025
766604d
Adding many-net-filter tests
knassre-bodo Nov 26, 2025
a538bb2
[RUN CI]
knassre-bodo Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions demos/notebooks/4_tpch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@
" .CALCULATE(global_avg_balance=AVG(selected_customers.WHERE(account_balance > 0.0).account_balance))\n",
" .customers\n",
" .CALCULATE(cntry_code=phone[:2])\n",
" .WHERE(is_selected_code & (account_balance > global_avg_balance) & (COUNT(orders) == 0))\n",
" .WHERE(is_selected_code & (account_balance > global_avg_balance) & HASNOT(orders))\n",
" .PARTITION(\n",
" name=\"countries\",\n",
" by=cntry_code,\n",
Expand All @@ -1695,7 +1695,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "pydough",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion pydough/conversion/hybrid_syncretizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def add_extension_semi_anti_count_filter(
HybridFilter(
tree.pipeline[-1],
HybridFunctionExpr(
pydop.GRT if is_semi else pydop.EQU,
pydop.NEQ if is_semi else pydop.EQU,
[agg_ref, literal_zero],
BooleanType(),
),
Expand Down
18 changes: 12 additions & 6 deletions pydough/conversion/hybrid_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def insert_count_filter(self, child_idx: int, is_semi: bool) -> None:
condition: HybridExpr
if is_semi:
condition = HybridFunctionExpr(
pydop.GRT,
pydop.NEQ,
[result_ref, HybridLiteralExpr(Literal(0, NumericType()))],
BooleanType(),
)
Expand Down Expand Up @@ -588,6 +588,16 @@ def add_child(
self
)

# Augment the reverse cardinality if the parent does not always exist.
if not reverse_cardinality.filters:
if len(self.pipeline) == 1 and isinstance(
self.pipeline[0], HybridPartition
):
if self.parent is not None and not self.parent.always_exists():
reverse_cardinality = reverse_cardinality.add_filter()
elif not self.always_exists():
reverse_cardinality = reverse_cardinality.add_filter()

# Create and insert the new child connection.
new_child_idx = len(self.children)
connection: HybridConnection = HybridConnection(
Expand All @@ -601,10 +611,6 @@ def add_child(
)
self._children.append(connection)

# Augment the reverse cardinality if the parent does not always exist.
if (not reverse_cardinality.filters) and (not self.always_exists()):
connection.reverse_cardinality = reverse_cardinality.add_filter()

# If an operation prevents the child's presence from directly
# filtering the current level, update its connection type to be either
# SINGULAR or AGGREGATION, then insert a similar COUNT(*)/PRESENT
Expand Down Expand Up @@ -852,7 +858,7 @@ def is_singular(self) -> bool:
case _:
return False
# The current level is fine, so check any levels above it next.
return True if self.parent is None else self.parent.always_exists()
return True if self.parent is None else self.parent.is_singular()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

@knassre-bodo knassre-bodo Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug in the previous version that I happened to notice. This function is checking if a hybrid tree is singular with regards to its parent context, which mis true if the current level is singular + all levels above it are also singular.


def equals_ignoring_successors(self, other: "HybridTree") -> bool:
"""
Expand Down
Loading