-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cubesql): Penalize zero members in wrapper (#8927)
This would allow to extract fully assembled `CubeScan` under wrapper instead of `CubeScan(allMembers, ungrouped=true)`. Before this there were 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. 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: * Support member alias for TD with granularity Before this schema compiler didn't use aliases for `cube.timeDimension.granularity` members * Extract ColumnRemapping and Remapper structs * Implement column remapping and literal member handling for `CubeScan` in wrapper Now column names, introduced by DataFusion, would get renamed, and that would avoid sending too long or incorrect aliases to Cube for SQL generation, and later to data source. DF can generate names like `datetrunc(Utf8("day"),Orders.createdAt)`, and aliases like that are not expected by JS side Single `CubeScan` can represent join of multiple `TableScan`s, they can have different table aliases, and column expressions on top of `CubeScan` in original plan can have different qualifiers. But generated SQL can have only one table alias, so all column expressions on top needs to be remapped to that single alias as well. * Support literal members in CubeScan under wrapper Now SQL generated for `CubeScan` will not skip literal members from CubeSCan, and generate SELECT wrapper with literal members as literal columns.
- Loading branch information
Showing
7 changed files
with
662 additions
and
155 deletions.
There are no files selected for viewing
This file contains 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 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 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
Oops, something went wrong.