Skip to content
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

[date](fix) modify push-down predicate for datev1 type #25781

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions be/src/exprs/bloom_filter_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down
6 changes: 0 additions & 6 deletions be/src/vec/exec/scan/vscan_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,13 @@ 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;
}
if (slot->type().is_array_type()) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,6 @@ private Expression processDateLikeTypeCoercion(ComparisonPredicate cp, Expressio
}
}

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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;
Expand Down Expand Up @@ -64,13 +63,6 @@ void testSimplifyComparisonPredicateRule() {
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));
Expand Down