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): Penalize zero members in wrapper #8927

Merged
merged 9 commits into from
Dec 17, 2024

Conversation

mcheshkov
Copy link
Member

Check List

  • Tests has 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)

This would allow to extract fully assembled CubeScan under wrapper instead of CubeScan(allMembers, ungrouped=true).

ATM there are two related components in cost: non_detected_cube_scans and cube_members
non_detected_cube_scans allows to penalize CubeScan without members specifically outside the wrapper. This is pretty hard penalty, queries like that are Not Good™
cube_members allows to prefer queries will less members, which seems fine. But on it's own it would prefer query with zero member, which is, actually, all the members.
So, new cost component added: zero_members_wrapper. It would stand right before cube_members, and allow to penalize no-members representation before cube_members starts impacting extraction.

New CubeScan extractions surfaced a couple of bugs related to aliasing in generated SQL, hence all the supporting stuff in this PR.

@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from eca2925 to da51ec9 Compare November 7, 2024 17:16
Copy link

vercel bot commented Nov 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2024 0:57am

@mcheshkov mcheshkov marked this pull request as ready for review November 7, 2024 22:36
@mcheshkov mcheshkov requested review from a team as code owners November 7, 2024 22:36
@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from da51ec9 to 6376543 Compare November 13, 2024 12:13
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 96.48241% with 14 lines in your changes missing coverage. Please review.

Project coverage is 82.85%. Comparing base (cb507c1) to head (7ee68a1).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...t/cubesql/cubesql/src/compile/engine/df/wrapper.rs 94.37% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8927      +/-   ##
==========================================
+ Coverage   82.80%   82.85%   +0.05%     
==========================================
  Files         221      221              
  Lines       78545    78813     +268     
==========================================
+ Hits        65037    65300     +263     
- Misses      13508    13513       +5     
Flag Coverage Δ
cubesql 82.85% <96.48%> (+0.05%) ⬆️

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 force-pushed the penalize-zero-members-in-wrapper branch from 6376543 to cc05fdc Compare November 27, 2024 12:56
@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from cc05fdc to 9ce4579 Compare December 13, 2024 15:54
@mcheshkov mcheshkov requested a review from a team as a code owner December 13, 2024 15:54
@mcheshkov mcheshkov marked this pull request as draft December 13, 2024 20:26
@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from 9ce4579 to 76eec8b Compare December 13, 2024 20:30
@mcheshkov
Copy link
Member Author

Due to our build order issues I can't add smoke test in the same PR, so I'll split it to separate one

@mcheshkov mcheshkov marked this pull request as ready for review December 13, 2024 22:25
@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from 76eec8b to 6a0a1a7 Compare December 17, 2024 01:52
@mcheshkov
Copy link
Member Author

I was confused, and actually I can add a smoke test here! And it was failing for a good reason!
Fixed and updated.

@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from 6a0a1a7 to 421c226 Compare December 17, 2024 02:02
* Now column names, introudced by Datafusion, would get renamed, and that would avoid sending too long aliases to Cube for SQL generation, and later to data source
* Single CubeScan can represent join of multiple TableScans, they can have different table aliases, and columns on top of CubeScan can have different qualifiers. But generated SQL can have only one table alias, so all column expressions on top needs to be remapped as well
@mcheshkov mcheshkov force-pushed the penalize-zero-members-in-wrapper branch from 421c226 to 7ee68a1 Compare December 17, 2024 11:54
@mcheshkov mcheshkov merged commit 171ea35 into master Dec 17, 2024
71 checks passed
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.

3 participants