You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ga...@apache.org on 2023/01/19 06:14:55 UTC
[doris] branch master updated: [Bug](predicate) fix date predicate (#16053)
This is an automated email from the ASF dual-hosted git repository.
gabriellee 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 6e090e4daf [Bug](predicate) fix date predicate (#16053)
6e090e4daf is described below
commit 6e090e4daf485a8732d0c8f55c71ca348456f938
Author: Gabriel <ga...@gmail.com>
AuthorDate: Thu Jan 19 14:14:48 2023 +0800
[Bug](predicate) fix date predicate (#16053)
---
be/src/vec/exec/scan/vscan_node.cpp | 5 ++++
.../data/correctness_p0/test_pushdown_constant.out | 6 +++++
.../correctness_p0/test_pushdown_constant.groovy | 31 +++++++++++++++++++---
3 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp
index 7b00afb748..21a38c6595 100644
--- a/be/src/vec/exec/scan/vscan_node.cpp
+++ b/be/src/vec/exec/scan/vscan_node.cpp
@@ -646,6 +646,11 @@ bool VScanNode::_is_predicate_acting_on_slot(
// the type of predicate not match the slot's type
return false;
}
+ } else if (child_contains_slot->type().is_datetime_type() &&
+ child_contains_slot->node_type() == doris::TExprNodeType::CAST_EXPR) {
+ // Expr `CAST(CAST(datetime_col AS DATE) AS DATETIME) = datetime_literal` should not be
+ // push down.
+ return false;
}
*range = &(entry->second.second);
return true;
diff --git a/regression-test/data/correctness_p0/test_pushdown_constant.out b/regression-test/data/correctness_p0/test_pushdown_constant.out
index 095c7b2035..724665a290 100644
--- a/regression-test/data/correctness_p0/test_pushdown_constant.out
+++ b/regression-test/data/correctness_p0/test_pushdown_constant.out
@@ -2,3 +2,9 @@
-- !sql --
1
+-- !select_all --
+2022-01-01 2022-01-01T11:11:11
+
+-- !predicate --
+2022-01-01 2022-01-01T11:11:11
+
diff --git a/regression-test/suites/correctness_p0/test_pushdown_constant.groovy b/regression-test/suites/correctness_p0/test_pushdown_constant.groovy
index d392781373..dd38166017 100644
--- a/regression-test/suites/correctness_p0/test_pushdown_constant.groovy
+++ b/regression-test/suites/correctness_p0/test_pushdown_constant.groovy
@@ -16,9 +16,10 @@
// under the License.
suite("test_pushdown_constant") {
- sql """ DROP TABLE IF EXISTS `test_pushdown_constant` """
+ def tblName = "test_pushdown_constant"
+ sql """ DROP TABLE IF EXISTS `${tblName}` """
sql """
- CREATE TABLE IF NOT EXISTS `test_pushdown_constant` (
+ CREATE TABLE IF NOT EXISTS `${tblName}` (
`id` int
) ENGINE=OLAP
AGGREGATE KEY(`id`)
@@ -31,11 +32,33 @@ suite("test_pushdown_constant") {
);
"""
sql """
- insert into test_pushdown_constant values(1);
+ insert into ${tblName} values(1);
"""
qt_sql """
- select 1 from test_pushdown_constant where BITMAP_MAX( BITMAP_AND(BITMAP_EMPTY(), coalesce(NULL, bitmap_empty()))) is NULL;
+ select 1 from ${tblName} where BITMAP_MAX( BITMAP_AND(BITMAP_EMPTY(), coalesce(NULL, bitmap_empty()))) is NULL;
"""
+ sql """ DROP TABLE IF EXISTS `${tblName}` """
+
+ sql """
+ CREATE TABLE IF NOT EXISTS `${tblName}` (
+ `c1` date,
+ `c2` datetime
+ ) ENGINE=OLAP
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH(`c1`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+ sql """
+ insert into ${tblName} values('20220101', '20220101111111');
+ """
+
+ qt_select_all """ select * from ${tblName} """
+ qt_predicate """ select * from ${tblName} where cast(c2 as date) = date '2022-01-01'"""
+ sql """ DROP TABLE IF EXISTS `${tblName}` """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org