This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 80d2e6f4c1 [fix](nereids) should not assign stats after cast on the
original slot (#18061)
80d2e6f4c1 is described below
commit 80d2e6f4c1815017e467ceb61344be9d3e581350
Author: minghong <[email protected]>
AuthorDate: Fri Mar 24 21:37:06 2023 +0800
[fix](nereids) should not assign stats after cast on the original slot
(#18061)
select * from T where A = 10.0
suppose A is int column
after stats derive on `cast(A as double) = 10.0`,
we set column stats for `cast(A as double)` on `A`
---
.../doris/nereids/stats/FilterEstimation.java | 24 +++++++---------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
index e58f06105e..f2904d38af 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java
@@ -20,6 +20,7 @@ package org.apache.doris.nereids.stats;
import org.apache.doris.nereids.stats.FilterEstimation.EstimationContext;
import org.apache.doris.nereids.trees.TreeNode;
import org.apache.doris.nereids.trees.expressions.And;
+import org.apache.doris.nereids.trees.expressions.Cast;
import org.apache.doris.nereids.trees.expressions.ComparisonPredicate;
import org.apache.doris.nereids.trees.expressions.CompoundPredicate;
import org.apache.doris.nereids.trees.expressions.EqualTo;
@@ -210,25 +211,14 @@ public class FilterEstimation extends
ExpressionVisitor<Statistics, EstimationCo
if (statsForLeft.histogram != null) {
return estimateEqualToWithHistogram(cp.left(), statsForLeft,
val, context);
}
- // cp.left : func(A), we assume func(A) has same statistics with A
- // for example: cast(N_NAME as varchar(*)) = 'GERMANY',
- // we assume cast(N_NAME as varchar(*)) and N_NAME have the same
col stats
- Set<Slot> leftSlots = cp.left().getInputSlots();
- Preconditions.checkArgument(leftSlots.size() <= 1,
- "stats derive: equal condition only support at one column,
but we meet "
- + leftSlots.size()
- );
Statistics equalStats = context.statistics.withSel(selectivity);
- /*
- leftSlots could be empty, for example:
- select * from (select 'jj' as kk1, sum(k2) from ${tableName2}
where k10 = '2015-04-02' group by kk1)tt
- where kk1 in ('jj')
- kk1 in ('jj') => kk1 = 'jj' => 'jj'='jj
- TODO const fold could eliminate this equalTo.
- */
- if (!leftSlots.isEmpty()) {
- Slot leftSlot = leftSlots.iterator().next();
+ Expression left = cp.left();
+ if (left instanceof Cast) {
+ left = ((Cast) left).child();
+ }
+ if (left instanceof SlotReference) {
+ Slot leftSlot = (SlotReference) left;
//update min/max of cp.left
ColumnStatistic columnStats =
equalStats.findColumnStatistics(leftSlot);
ColumnStatisticBuilder colStatsBuilder = new
ColumnStatisticBuilder(columnStats);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]