-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add framework of mv selector #4014
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
Conversation
fe/src/main/java/org/apache/doris/analysis/MVColumnHLLUnionPatten.java
Outdated
Show resolved
Hide resolved
2f2fba8 to
8a82ce5
Compare
fe/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
Outdated
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
Outdated
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/rewrite/mvrewrite/CountFieldToSum.java
Outdated
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/rewrite/mvrewrite/HLLHashToSlotRefRule.java
Outdated
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/rewrite/mvrewrite/MVExprEquivalent.java
Outdated
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/rewrite/mvrewrite/SlotRefEqualRule.java
Show resolved
Hide resolved
fe/src/main/java/org/apache/doris/rewrite/mvrewrite/ToBitmapToSlotRefRule.java
Outdated
Show resolved
Hide resolved
| return true; | ||
| } else { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
41-47 can rewrite:
SlotRef slotRef = functionCallExpr.getChild(0).unwrapSlotRef();
return slotRef != null;
| FN_NAME_TO_PATTERN.put("count", new MVColumnOneChildPattern("count")); | ||
| FN_NAME_TO_PATTERN.put("bitmap_union", new MVColumnBitmapUnionPattern()); | ||
| FN_NAME_TO_PATTERN.put("hll_union", new MVColumnHLLUnionPattern()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comment which pattern is suitable for AggregateModel, which pattern is suitable for DuplicatedModel? if it is a need to add a type to distinguish the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patterns in here do not distinguish Agg model and duplicate model. These patterns are compatible.
73cf136 to
e9ab81e
Compare
HangyuanLiu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
morningman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…a materialized view.
This commit mainly supports creating bitmap_union, hll_union, and count materialized views.
* The main changes are as follows:
1. When creating a materialized view, doris judge the semantic analysis of the newly supported aggregate function.
Only bitmap_union(to_bitmap(column)), hll_union(hll_hash(column)) and count(column) are supported.
2. Match the correct materialized view when querying.
After the user sends the query, if there is a possibility of matching the materialized view, the query will be rewritten firstly.
Such as:
Table: k1 int, k2 int
MV: k1 int, mv_bitmap_union_k2 bitmap mv_bitmap_union
mv_bitmap_union = to_bitmap(k2)
Query: select k1, count(distinct k2) from Table
Found that there is a match between the materialized view column and the query column, the query is rewritten as:
Rewritten query: select k1, bitmap_union_count(mv_bitmap_union_k2) from table
Then when the materialized view is matched, it can be matched to the query materialized view table.
Sometimes the rewritten query may not match any materialized view, which means that the rewriting failed. The query needs to be re-parsed and executed again.
Change-Id: I96a7522c4e6a58150b0df1886cf22c895c1c2bad
Change-Id: I4c8568d4b57384c342eaf5432856eaaa7393f49d
Change-Id: Ibdc44e527279308d6cad77aa7f1d230d27abd02e
Change-Id: I313b896c20a210ce5a2d9ccbc5ca6d8e78ade3e7
Change-Id: I897301af916b96377664df2d321aad3c4a2b24e1
Change-Id: Ibf277124144e012773de310a17cb5cd57cdc76de
Change-Id: I8feab7ac56aa17412bbf45b15b41754f3f3b7410
Change-Id: I73bd860091b14202acb731a0eab460d992237f03
Change-Id: Ib8ab5fa56b1caec597937f6bf3defa4acfe8aab1
Change-Id: If3e553ebb29e59b0e35ed4423094ad8caaa710ac
Change-Id: Id867098ded33667a0f80f67daf88ee068a1973a0
Change-Id: I3d5481fab5a09bf5f43b606d1fe0bda41eb2e17b
Change-Id: I38273603ae21245b38e0aa5dd2b266aceab06575
Change-Id: Id42b9102585901e647d56601e61c0a5d53a7208c
Change-Id: I6e16b29f8cdcd8fa4772d235fbeddae6b7ec9511
Change-Id: I6656a91208fa58bd870977a6a873bcd9cf9893c9
Change-Id: Id9106590c48052ace64eea26831f7e283dddb0de
morningman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
morningman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This commit mainly supports creating bitmap_union, hll_union, and count materialized views.
When creating a materialized view, doris judge the semantic analysis of the newly supported aggregate function.
Only bitmap_union(to_bitmap(column)), hll_union(hll_hash(column)) and count(column) are supported.
Match the correct materialized view when querying.
After the user sends the query, if there is a possibility of matching the materialized view, the query will be rewritten firstly.
Such as:
Table: k1 int, k2 int
MV: k1 int, mv_bitmap_union_k2 bitmap mv_bitmap_union
mv_bitmap_union = to_bitmap(k2)
Query: select k1, count(distinct k2) from Table
Found that there is a match between the materialized view column and the query column, the query is rewritten as:
Rewritten query: select k1, bitmap_union_count(mv_bitmap_union_k2) from table
Then when the materialized view is matched, it can be matched to the query materialized view table.
Sometimes the rewritten query may not match any materialized view, which means that the rewriting failed. The query needs to be re-parsed and executed again.