-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[fix](mtmv) Fix result wrong when query rewrite by mv if query contains null_unsafe equals expression #39629
[fix](mtmv) Fix result wrong when query rewrite by mv if query contains null_unsafe equals expression #39629
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
run buildall |
TPC-H: Total hot run time: 38446 ms
|
Map<Set<SlotReference>, Set<SlotReference>> equivalenceClassSetMap = new HashMap<>(); | ||
List<Set<SlotReference>> sourceSets = source.getEquivalenceSetList(); | ||
List<Set<SlotReference>> targetSets = target.getEquivalenceSetList(); | ||
Map<List<SlotReference>, List<SlotReference>> equivalenceClassSetMap = new HashMap<>(); |
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.
why change set to list could fix this problem?
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.
such as the expression o_orderstatus = o_orderstatus
we should compensate o_orderstatus = o_orderstatus
on materialized view.
If we record the slot equal expression in set, only get {o_orderstatus}
, in Predicates#compensateEquivalence
we couldn't compensate filter.
Change set to list. we get {o_orderstatus, o_orderstatus}
, then we can compensate filter by Predicates#compensateEquivalence
.
…ns null_unsafe equals expression
9ba2d25
to
1a6fb3c
Compare
run buildall |
TPC-H: Total hot run time: 37305 ms
|
TPC-DS: Total hot run time: 191331 ms
|
ClickBench: Total hot run time: 30.15 s
|
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
…ns null_unsafe equals expression (apache#39629) Fix result wrong when query rewrite by mv if query contains null_unsafe equals expression and the expression both side is slot table orders data is as following: (null, 1, 'o', 9.5, '2023-12-08', 'a', 'b', 1, 'yy'), (1, null, 'o', 10.5, '2023-12-08', 'a', 'b', 1, 'yy'), (2, 1, null, 11.5, '2023-12-09', 'a', 'b', 1, 'yy'), (3, 1, 'o', null, '2023-12-10', 'a', 'b', 1, 'yy'), (3, 1, 'o', 33.5, null, 'a', 'b', 1, 'yy'), (4, 2, 'o', 43.2, '2023-12-11', null,'d',2, 'mm'), (5, 2, 'o', 56.2, '2023-12-12', 'c',null, 2, 'mi'), (5, 2, 'o', 1.2, '2023-12-12', 'c','d', null, 'mi'); such as mv def is select count(*), o_orderstatus, o_comment from orders group by o_orderstatus, o_comment; query is as following: select count(*), o_orderstatus, o_comment from orders where o_orderstatus = o_orderstatus group by o_orderstatus, o_comment; after rewrite by materialized view, the result is wrong as following, the row contains null should not appear +----------+---------------+-----------+ | count(*) | o_orderstatus | o_comment | +----------+---------------+-----------+ | 1 | NULL | yy | | 1 | o | mm | | 2 | o | mi | | 4 | o | yy | +----------+---------------+-----------+
…ns null_unsafe equals expression (#39629) Fix result wrong when query rewrite by mv if query contains null_unsafe equals expression and the expression both side is slot table orders data is as following: (null, 1, 'o', 9.5, '2023-12-08', 'a', 'b', 1, 'yy'), (1, null, 'o', 10.5, '2023-12-08', 'a', 'b', 1, 'yy'), (2, 1, null, 11.5, '2023-12-09', 'a', 'b', 1, 'yy'), (3, 1, 'o', null, '2023-12-10', 'a', 'b', 1, 'yy'), (3, 1, 'o', 33.5, null, 'a', 'b', 1, 'yy'), (4, 2, 'o', 43.2, '2023-12-11', null,'d',2, 'mm'), (5, 2, 'o', 56.2, '2023-12-12', 'c',null, 2, 'mi'), (5, 2, 'o', 1.2, '2023-12-12', 'c','d', null, 'mi'); such as mv def is select count(*), o_orderstatus, o_comment from orders group by o_orderstatus, o_comment; query is as following: select count(*), o_orderstatus, o_comment from orders where o_orderstatus = o_orderstatus group by o_orderstatus, o_comment; after rewrite by materialized view, the result is wrong as following, the row contains null should not appear +----------+---------------+-----------+ | count(*) | o_orderstatus | o_comment | +----------+---------------+-----------+ | 1 | NULL | yy | | 1 | o | mm | | 2 | o | mi | | 4 | o | yy | +----------+---------------+-----------+
Proposed changes
Fix result wrong when query rewrite by mv if query contains null_unsafe equals expression and the expression both side is slot
table orders data is as following:
such as mv def is
query is as following:
after rewrite by materialized view, the result is wrong as following, the row contains null should not appear
the pr fix this