-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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](nereids)Support date_trunc function in partition prune #38025
[Feat](nereids)Support date_trunc function in partition prune #38025
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: 39773 ms
|
TPC-DS: Total hot run time: 174509 ms
|
ClickBench: Total hot run time: 30.69 s
|
cd0a714
to
8644094
Compare
run buildall |
TPC-H: Total hot run time: 40013 ms
|
TPC-DS: Total hot run time: 172812 ms
|
ClickBench: Total hot run time: 30.43 s
|
run buildall |
TPC-H: Total hot run time: 39580 ms
|
TPC-DS: Total hot run time: 173096 ms
|
ClickBench: Total hot run time: 31.97 s
|
b5ff552
to
8a377af
Compare
run buildall |
TPC-H: Total hot run time: 39121 ms
|
TPC-DS: Total hot run time: 172563 ms
|
ClickBench: Total hot run time: 30.67 s
|
|
||
@Override | ||
public Monotonicity getMonotonicity() { | ||
return new Monotonicity(true, true); |
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.
maybe, u should use some static variables generated in Monotonicity class. refer to org.apache.doris.nereids.properties.PhysicalProperties
public Expression withConstantArgs(Literal literal) { | ||
return this; | ||
} | ||
|
||
public int getMonotonicFunctionChildIndex() { | ||
return -1; | ||
} | ||
|
||
public Monotonicity getMonotonicity() { | ||
return new Monotonicity(false, true); | ||
} |
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.
add comment to these interfaces
@@ -46,4 +58,16 @@ public boolean isHighOrder() { | |||
public final String getName() { | |||
return name; | |||
} | |||
|
|||
public Expression withConstantArgs(Literal literal) { | |||
return this; |
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.
return this is not a good idea. i think we should throw exceptions if on function not support Monotonicity
public class Monotonicity { | ||
public boolean isMonotonic; | ||
public boolean isPositive; | ||
|
||
public Monotonicity(boolean isMonotonic, boolean isPositive) { | ||
this.isMonotonic = isMonotonic; | ||
this.isPositive = isPositive; | ||
} | ||
} |
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.
move out from function, it should be expression trait?
public EvaluateRangeResult visitDateTrunc(DateTrunc dateTrunc, EvaluateRangeInput context) { | ||
EvaluateRangeResult result = super.visitDateTrunc(dateTrunc, context); | ||
if (!(result.result instanceof DateTrunc)) { | ||
return result; | ||
} | ||
Expression dateTruncChild = dateTrunc.child(0); | ||
if (partitionSlotContainsNull.containsKey(dateTruncChild)) { | ||
partitionSlotContainsNull.put(dateTrunc, true); | ||
} | ||
return computeMonotonicFunctionRange(result); | ||
} |
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.
if we add a new trait class Monotonic for expression, could we here use visit Monotoic to do same things for all monotonic functions? then we only need add trait on different function
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.
we should use trait interface
public interface Monotonic extends ExpressionTrait {
boolean isPositive();
}
public class DateTrunc implement Monotonic {
@Override
public isPositive() {
return true;
}
}
@@ -69,6 +69,10 @@ public boolean isEmptyRange() { | |||
return rangeSet.isEmpty(); | |||
} | |||
|
|||
public boolean isCompletelyInfinite() { | |||
return !span().hasLowerBound() && !span().hasUpperBound(); |
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.
I think this is not completeInfinite
new ColumnRange(
ColumnBound.lessThen(Literal.of(0)))
.union(ColumnRange.greaterThan(Literal.of(10))
);
assert slotResult != null; | ||
assert slotResult.columnRanges.containsKey(slot); |
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.
assert only throw exception in test environment
public EvaluateRangeResult visitDateTrunc(DateTrunc dateTrunc, EvaluateRangeInput context) { | ||
EvaluateRangeResult result = super.visitDateTrunc(dateTrunc, context); | ||
if (!(result.result instanceof DateTrunc)) { | ||
return result; | ||
} | ||
Expression dateTruncChild = dateTrunc.child(0); | ||
if (partitionSlotContainsNull.containsKey(dateTruncChild)) { | ||
partitionSlotContainsNull.put(dateTrunc, true); | ||
} | ||
return computeMonotonicFunctionRange(result); | ||
} |
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.
we should use trait interface
public interface Monotonic extends ExpressionTrait {
boolean isPositive();
}
public class DateTrunc implement Monotonic {
@Override
public isPositive() {
return true;
}
}
8a377af
to
0dae430
Compare
run buildall |
TPC-H: Total hot run time: 41509 ms
|
TPC-DS: Total hot run time: 170487 ms
|
ClickBench: Total hot run time: 30.52 s
|
run cloud_p0 |
1 similar comment
run cloud_p0 |
run buildall |
TPC-H: Total hot run time: 41946 ms
|
run buildall |
TPC-H: Total hot run time: 41565 ms
|
TPC-DS: Total hot run time: 169883 ms
|
ClickBench: Total hot run time: 29.96 s
|
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
let range partition pruner support date_trunc(dt, 'day') > 10. For example, partition column is dt, there is a partition ('2020-01-01 10:00:00', '2020-02-05 10:00:00'), and a predicate date_trunc(dt, 'day')<'2019-01-01 ', this partition can be pruned.
…e#38025) let range partition pruner support date_trunc(dt, 'day') > 10. For example, partition column is dt, there is a partition ('2020-01-01 10:00:00', '2020-02-05 10:00:00'), and a predicate date_trunc(dt, 'day')<'2019-01-01 ', this partition can be pruned.
…8897) introduced by #38025 Or expression evaluate wrongly in #38025. For example, partition column is a, b, predicate is a=a or b>1 , partition column range is min<a<5, b is infinite. The evaluate result of or expression should be b is infinite(because when a is not null, a=a is true, there is no restrict for b, e.g. a=1, b=0 satisfy a=a or b>1). #38025 pr has wrongly evaluate result b >1
…8897) introduced by #38025 Or expression evaluate wrongly in #38025. For example, partition column is a, b, predicate is a=a or b>1 , partition column range is min<a<5, b is infinite. The evaluate result of or expression should be b is infinite(because when a is not null, a=a is true, there is no restrict for b, e.g. a=1, b=0 satisfy a=a or b>1). #38025 pr has wrongly evaluate result b >1
…ache#38897) introduced by apache#38025 Or expression evaluate wrongly in apache#38025. For example, partition column is a, b, predicate is a=a or b>1 , partition column range is min<a<5, b is infinite. The evaluate result of or expression should be b is infinite(because when a is not null, a=a is true, there is no restrict for b, e.g. a=1, b=0 satisfy a=a or b>1). apache#38025 pr has wrongly evaluate result b >1
…e#38025) let range partition pruner support date_trunc(dt, 'day') > 10. For example, partition column is dt, there is a partition ('2020-01-01 10:00:00', '2020-02-05 10:00:00'), and a predicate date_trunc(dt, 'day')<'2019-01-01 ', this partition can be pruned.
The nereids range partition pruner does not support date_trunc(dt, 'day')>10. This pr supports to compute date_trunc(dt, 'day')>10. For example, there is a partition ('2020-01-01 10:00:00', '2020-02-05 10:00:00') ,partition column is dt, and a predicate date_trunc(dt, 'day')<'2019-01-01 ', this partition can be pruned.