Skip to content
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

feat(cubesql): Add separate ungrouped_scan flag to wrapper replacer context #9120

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mcheshkov
Copy link
Member

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made (if issue reference is not provided)

It is used to track whether WrappedSelect actually wraps ungrouped scan as opposed to old flag, which is used as push to Cube enabler.

Changes in cost are necessary because now ungrouped scans are tracked, we are getting proper values in wrapped_select_ungrouped_scan cost component, it would count the WrappedSelect(ungrouped_scan=true) nodes in extracted plan. And with old cost it would turns any ungrouped scan under wrapper more expensive than plan with same amount of wrappers (usually it's just 1 anyway), but with more nodes outside wrapper. Consider consuming projection: Projection(WrappedSelect(ungrouped_scan=true)) vs WrappedSelect(from=WrappedSelect(ungrouped_scan=true), ungrouped_scan=true). Plan with Projection would have ast_size_outside_wrapper=1 wrapped_select_ungrouped_scan=1, plan with WrappedSelect - ast_size_outside_wrapper=0 wrapped_select_ungrouped_scan=2, and second one is preferrable.

Also couple of related fixes:

  • Mark distinct WrappedSelect as grouped
  • Depend on a ungrouped flag for grouped join part: Wrapper can be ungrouped=true, push_to_cube=false, and this is unexpected in ungrouped-grouped join.

…ontext

It is used to track whether this query actually wraps ungrouped scan in from as opposed to old flag, which is used as push to cube enabler

Changes in cost are necessary because now that it is tracked, we are getting proper values in `wrapped_select_ungrouped_scan` cost component, and it turns any ungrouped scan under wrapper more expensive than plan with same amount of wrappers (usually it's just 1 anyway), but with more nodes outside wrapper
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 97.89030% with 5 lines in your changes missing coverage. Please review.

Project coverage is 83.07%. Comparing base (39190e0) to head (fd99643).

Files with missing lines Patch % Lines
...ubesql/src/compile/rewrite/rules/wrapper/filter.rs 95.65% 2 Missing ⚠️
...ql/src/compile/rewrite/rules/wrapper/projection.rs 96.07% 2 Missing ⚠️
...compile/rewrite/rules/wrapper/cube_scan_wrapper.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9120      +/-   ##
==========================================
+ Coverage   83.03%   83.07%   +0.03%     
==========================================
  Files         226      226              
  Lines       79482    79672     +190     
==========================================
+ Hits        66000    66184     +184     
- Misses      13482    13488       +6     
Flag Coverage Δ
cubesql 83.07% <97.89%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcheshkov mcheshkov marked this pull request as ready for review January 21, 2025 11:21
@mcheshkov mcheshkov requested a review from a team as a code owner January 21, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant