Repository navigation
[Data] Derive required columns through Join in ProjectionPushdown - #68158
Conversation
Signed-off-by: Jie-Kai Chang <[email protected]>
Signed-off-by: Jie-Kai Chang <[email protected]>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit d96b301. Configure here.
| required: pruning the other would make the physical join stop | ||
| suffixing the survivor, changing the output name the consumer uses. | ||
| """ | ||
| output_schema = self.infer_schema() |
There was a problem hiding this comment.
I just find out we didnt cache join inferred schema in the op, can you add that in a follow up?
There was a problem hiding this comment.
Sure, I'll do that in a follow-up.
| # prune when every aggregation declares the column it reads. | ||
| if not isinstance(agg, AggregateFnV2): | ||
| new_op = op._with_new_input_dependencies(new_inputs) | ||
| if required is not None and op.infer_schema() is not None: |
There was a problem hiding this comment.
Why skip check when op.infer_schema() is None? I think we should still return original op if we cannot infer?
There was a problem hiding this comment.
Fixed in f75150f, with one difference from your suggestion. Returning op whenever the schema is unknown would also drop pruning below UDF maps and below aggregates with undeclared output types (Unique, Quantile, ...). Instead, when the output schema is unknown it checks that each input the operator narrowed still provides what was asked, and returns op if not.
…able shuffles Signed-off-by: Jie-Kai Chang <[email protected]>
…nto releases/2.61.0 (#68472) ## Description Cherry-pick of #68433 (`1729626bbb`) onto `releases/2.61.0`. Lets the upstream read or map fuse into the disk-shuffle writer, and sets the polars thread limit inside the task rather than through the runtime env. The pick applied without conflicts. Seven master commits that touch the same files are not on the release branch (#67143, #68158, #68202 and its revert #68383, #68319, #67570, #68118), so the picked files differ from master in five places. Reviewers from Data, please confirm none of those is a prerequisite. ## Testing Ran locally against the `releases/2.61.0` wheel (`7c8ca5ea51`) with the picked files overlaid: `test_hash_shuffle_v2.py`, `test_operator_fusion.py` and `test_execution_optimizer_advanced.py`, 232 passed, 2 skipped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: You-Cheng Lin <[email protected]> Signed-off-by: elliot-barn <[email protected]> Co-authored-by: You-Cheng Lin <[email protected]>
## Description With #68158 we dont have to hand-prune unused columns anymore, it automatically push projection down. So we don't have to manually write projection in test scripts Can be merged after #68455 ## Related issues > Link related issues: "Fixes #1234", "Closes #1234", or "Related to #1234". ## Additional information > Optional: Add implementation details, API changes, usage examples, screenshots, etc. Signed-off-by: You-Cheng Lin <[email protected]>

Description
ProjectionPushdownnow derives the columns each operator needs from what its consumers reference, and carries that set down throughJoin,Aggregate,Sortand the other pass-through operators to the reads. A multi-table query no longer needs a hand-writtenselect_columnson every table.Before
Derivation stopped at the first non-
Projectoperator (the one exception was directly below anAggregate). Every TPC-H script therefore opens withload_table(...).select_columns([...])per table; without it, scans and shuffles run at full width.After
LogicalOperatorSupportsProjectionPassThrough.required_input_columns(): given the output columns its consumers need, an operator returns the columns each input must provide, or declines.ProjectionPushdown._derive_required_columnswalks the plan top-down once and inserts a pruningProjectbelow shuffles and on top of reads that can absorb it. The existing fuse and push-into-read steps do the rest.Joinsplits the set by side and adds what it reads itself: theonkeys, the condition keys and theconditioncolumns ([Data] AddconditiontoDataset.joinand extract equi-join keys from it #67590). It keeps both members of a suffixed collision, prunes the non-emitted side of a semi/anti join to its keys, and is left alone when its output schema can't be inferred.flowchart TD subgraph Before subgraph BS[Subsystem: logical planning] subgraph BR[ProjectionPushdown] B0[Project: select a, b] --> B1[Join on id] B1 --> B2["ReadParquet(left): id, a, unused_left"] B1 --> B3["ReadParquet(right): id, b, unused_right"] end end end subgraph After subgraph AS[Subsystem: logical planning] subgraph AR[ProjectionPushdown + required_input_columns] A0[Project: select a, b] --> A1[Join on id] A1 --> A2["ReadParquet(left): id, a"] A1 --> A3["ReadParquet(right): id, b"] end end end classDef changed fill:#fff9c4,stroke:#f9a825,color:#000 classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000 class A1 added class A2,A3 changedSubsystems
Logical planning / query optimization. The behavioral change is in
rules/projection_pushdown.py; the operator files only gain trait implementations.Benchmark
TPC-H Q7 (
release/nightly_tests/dataset/tpch/tpch_q7.py) on SF1 local Parquet, one 20-core node.select_columnskeptselect_columnsremoved from the 5 scansselect_columnsremovedRelated issues
Closes #66833
Additional information