This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 3d1206d3259 [date](fix) modify push-down predicate for datev1 type
(#25571)
3d1206d3259 is described below
commit 3d1206d32595104a6c60ab9f72828f0d8d3388bd
Author: Gabriel <[email protected]>
AuthorDate: Thu Oct 19 14:18:27 2023 +0800
[date](fix) modify push-down predicate for datev1 type (#25571)
For comparison predicate, two arguments must be cast to datetime and push
down to storage if either one is date type. This PR disables predicate
push-down for this case.
---
be/src/exprs/bloom_filter_func.h | 5 -----
be/src/pipeline/exec/scan_operator.cpp | 6 ------
be/src/vec/columns/predicate_column.h | 12 ------------
be/src/vec/exec/scan/vscan_node.cpp | 6 ------
.../rules/expression/rules/SimplifyComparisonPredicate.java | 10 ----------
.../expression/rules/SimplifyComparisonPredicateTest.java | 8 --------
6 files changed, 47 deletions(-)
diff --git a/be/src/exprs/bloom_filter_func.h b/be/src/exprs/bloom_filter_func.h
index 0a86a359902..330c939819c 100644
--- a/be/src/exprs/bloom_filter_func.h
+++ b/be/src/exprs/bloom_filter_func.h
@@ -434,11 +434,6 @@ struct DateFindOp : public
CommonFindOp<vectorized::VecDateTimeValue> {
vectorized::VecDateTimeValue date_value;
date_value.from_olap_date(value);
- // So confusing here. For join node with condition (a.date_col =
b.date_col), the actual
- // expression is CAST(a.date_col AS DATETIME) = CAST(b.date_col AS
DATETIME). So we build
- // this bloom filter by CAST(a.date_col AS DATETIME) and also need to
probe this bloom
- // filter by a datetime value.
- date_value.set_type(TimeType::TIME_DATETIME);
return bloom_filter.test(Slice((char*)&date_value,
sizeof(vectorized::VecDateTimeValue)));
}
diff --git a/be/src/pipeline/exec/scan_operator.cpp
b/be/src/pipeline/exec/scan_operator.cpp
index df45db62ed8..3e83e8a4a79 100644
--- a/be/src/pipeline/exec/scan_operator.cpp
+++ b/be/src/pipeline/exec/scan_operator.cpp
@@ -530,9 +530,6 @@ bool ScanLocalState<Derived>::_is_predicate_acting_on_slot(
template <typename Derived>
bool ScanLocalState<Derived>::_ignore_cast(SlotDescriptor* slot,
vectorized::VExpr* expr) {
- if (slot->type().is_date_type() && expr->type().is_date_type()) {
- return true;
- }
if (slot->type().is_string_type() && expr->type().is_string_type()) {
return true;
}
@@ -540,9 +537,6 @@ bool ScanLocalState<Derived>::_ignore_cast(SlotDescriptor*
slot, vectorized::VEx
if (slot->type().children[0].type == expr->type().type) {
return true;
}
- if (slot->type().children[0].is_date_type() &&
expr->type().is_date_type()) {
- return true;
- }
if (slot->type().children[0].is_string_type() &&
expr->type().is_string_type()) {
return true;
}
diff --git a/be/src/vec/columns/predicate_column.h
b/be/src/vec/columns/predicate_column.h
index 2f543e40211..c6a085acd6a 100644
--- a/be/src/vec/columns/predicate_column.h
+++ b/be/src/vec/columns/predicate_column.h
@@ -48,18 +48,6 @@ private:
using T = typename PredicatePrimitiveTypeTraits<Type>::PredicateFieldType;
using ColumnType = typename PrimitiveTypeTraits<Type>::ColumnType;
- uint64_t get_date_at(uint16_t idx) {
- const T val = data[idx];
- const char* val_ptr = reinterpret_cast<const char*>(&val);
- uint64_t value = 0;
- value = *(unsigned char*)(val_ptr + 2);
- value <<= 8;
- value |= *(unsigned char*)(val_ptr + 1);
- value <<= 8;
- value |= *(unsigned char*)(val_ptr);
- return value;
- }
-
void insert_date_to_res_column(const uint16_t* sel, size_t sel_size,
ColumnVector<Int64>* res_ptr) {
res_ptr->reserve(sel_size);
diff --git a/be/src/vec/exec/scan/vscan_node.cpp
b/be/src/vec/exec/scan/vscan_node.cpp
index 87a431fd27b..db4a4320a66 100644
--- a/be/src/vec/exec/scan/vscan_node.cpp
+++ b/be/src/vec/exec/scan/vscan_node.cpp
@@ -76,9 +76,6 @@ namespace doris::vectorized {
}
static bool ignore_cast(SlotDescriptor* slot, VExpr* expr) {
- if (slot->type().is_date_type() && expr->type().is_date_type()) {
- return true;
- }
if (slot->type().is_string_type() && expr->type().is_string_type()) {
return true;
}
@@ -86,9 +83,6 @@ static bool ignore_cast(SlotDescriptor* slot, VExpr* expr) {
if (slot->type().children[0].type == expr->type().type) {
return true;
}
- if (slot->type().children[0].is_date_type() &&
expr->type().is_date_type()) {
- return true;
- }
if (slot->type().children[0].is_string_type() &&
expr->type().is_string_type()) {
return true;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
index 74627eae9f7..b1c54d82a74 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java
@@ -188,16 +188,6 @@ public class SimplifyComparisonPredicate extends
AbstractExpressionRewriteRule {
}
}
- if (left.getDataType() == DateType.INSTANCE && right.getDataType() ==
DateType.INSTANCE) {
- // Date cp Date is not supported in BE storage engine. So cast to
DateTime
- left = new Cast(left, DateTimeType.INSTANCE);
- if (right instanceof DateLiteral) {
- DateLiteral l = (DateLiteral) right;
- right = new DateTimeLiteral(l.getYear(), l.getMonth(),
l.getDay(), 0, 0, 0);
- } else {
- right = new Cast(right, DateTimeType.INSTANCE);
- }
- }
if (left != cp.left() || right != cp.right()) {
return cp.withChildren(left, right);
} else {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicateTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicateTest.java
index 6735e31192f..f76683338c4 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicateTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicateTest.java
@@ -28,7 +28,6 @@ import
org.apache.doris.nereids.trees.expressions.literal.DateLiteral;
import org.apache.doris.nereids.trees.expressions.literal.DateTimeLiteral;
import org.apache.doris.nereids.trees.expressions.literal.DateTimeV2Literal;
import org.apache.doris.nereids.trees.expressions.literal.DateV2Literal;
-import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.DateTimeV2Type;
import com.google.common.collect.ImmutableList;
@@ -64,13 +63,6 @@ class SimplifyComparisonPredicateTest extends
ExpressionRewriteTestHelper {
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT),
dtv2),
new EqualTo(new Cast(dv2, DateTimeV2Type.SYSTEM_DEFAULT),
dtv2));
- // DateTimeV2 -> Date
- assertRewrite(
- new GreaterThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT),
dtv2),
- new GreaterThan(new Cast(d, DateTimeType.INSTANCE), new
DateTimeLiteral(1, 1, 1, 0, 0, 0)));
- assertRewrite(
- new LessThan(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
- new LessThan(new Cast(d, DateTimeType.INSTANCE), new
DateTimeLiteral(1, 1, 2, 0, 0, 0)));
assertRewrite(
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2),
new EqualTo(new Cast(d, DateTimeV2Type.SYSTEM_DEFAULT), dtv2));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]