From b8ebcdff784b6e7f76bd298f19a67b589e17e71f Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 1 Mar 2023 12:29:20 +0800 Subject: [PATCH] [Bug](bloomfilter) Fix wrong result using bloomfilter with date type (#17225) --- be/src/exprs/bloom_filter_func.h | 12 ++--------- .../date/test_date_runtime_filter.out | 20 +++++++++++++++++++ .../date/test_date_runtime_filter.groovy | 14 +++++++++++++ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/be/src/exprs/bloom_filter_func.h b/be/src/exprs/bloom_filter_func.h index 3d8f565aa3..31d7192546 100644 --- a/be/src/exprs/bloom_filter_func.h +++ b/be/src/exprs/bloom_filter_func.h @@ -312,22 +312,18 @@ struct FixedStringFindOp : public StringFindOp { } }; -struct DateTimeFindOp : public CommonFindOp { +struct DateTimeFindOp : public CommonFindOp { bool find_olap_engine(const BloomFilterAdaptor& bloom_filter, const void* data) const { vectorized::VecDateTimeValue value; value.from_olap_datetime(*reinterpret_cast(data)); return bloom_filter.test(Slice((char*)&value, sizeof(vectorized::VecDateTimeValue))); } - - void insert(BloomFilterAdaptor& bloom_filter, const void* data) const { - bloom_filter.add_bytes((char*)data, sizeof(vectorized::VecDateTimeValue)); - } }; // avoid violating C/C++ aliasing rules. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101684 -struct DateFindOp : public CommonFindOp { +struct DateFindOp : public CommonFindOp { bool find_olap_engine(const BloomFilterAdaptor& bloom_filter, const void* data) const { uint24_t date = *static_cast(data); uint64_t value = uint32_t(date); @@ -337,10 +333,6 @@ struct DateFindOp : public CommonFindOp { return bloom_filter.test(Slice((char*)&date_value, sizeof(vectorized::VecDateTimeValue))); } - - void insert(BloomFilterAdaptor& bloom_filter, const void* data) const { - bloom_filter.add_bytes((char*)data, sizeof(vectorized::VecDateTimeValue)); - } }; struct DecimalV2FindOp : public CommonFindOp { diff --git a/regression-test/data/datatype_p0/date/test_date_runtime_filter.out b/regression-test/data/datatype_p0/date/test_date_runtime_filter.out index a6051c0236..c860aebfe2 100644 --- a/regression-test/data/datatype_p0/date/test_date_runtime_filter.out +++ b/regression-test/data/datatype_p0/date/test_date_runtime_filter.out @@ -24,3 +24,23 @@ 2 2000-02-02 2000-02-02T11:11:11 2 2000-02-02 2000-02-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 +-- !sql2 -- +1 2000-01-01 2000-01-01T11:11:11 1 2000-01-01 2000-01-01T11:11:11 +2 2000-02-02 2000-02-02T11:11:11 2 2000-02-02 2000-02-02T11:11:11 +3 2000-03-02 2000-03-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 + +-- !sql2 -- +1 2000-01-01 2000-01-01T11:11:11 1 2000-01-01 2000-01-01T11:11:11 +2 2000-02-02 2000-02-02T11:11:11 2 2000-02-02 2000-02-02T11:11:11 +3 2000-03-02 2000-03-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 + +-- !sql2 -- +1 2000-01-01 2000-01-01T11:11:11 1 2000-01-01 2000-01-01T11:11:11 +2 2000-02-02 2000-02-02T11:11:11 2 2000-02-02 2000-02-02T11:11:11 +3 2000-03-02 2000-03-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 + +-- !sql2 -- +1 2000-01-01 2000-01-01T11:11:11 1 2000-01-01 2000-01-01T11:11:11 +2 2000-02-02 2000-02-02T11:11:11 2 2000-02-02 2000-02-02T11:11:11 +3 2000-03-02 2000-03-02T11:11:11 3 2000-03-02 2000-03-02T11:11:11 + diff --git a/regression-test/suites/datatype_p0/date/test_date_runtime_filter.groovy b/regression-test/suites/datatype_p0/date/test_date_runtime_filter.groovy index f1526c1517..109c0b5e85 100644 --- a/regression-test/suites/datatype_p0/date/test_date_runtime_filter.groovy +++ b/regression-test/suites/datatype_p0/date/test_date_runtime_filter.groovy @@ -45,5 +45,19 @@ suite("test_date_runtime_filter") { sql " set runtime_filter_type = 8; " qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c3 = b.c3 ORDER BY a.c2" + sql " set runtime_filter_wait_time_ms = 0; " + + sql " set runtime_filter_type = 1; " + qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c3 = b.c3 ORDER BY a.c2" + + sql " set runtime_filter_type = 2; " + qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c3 = b.c3 ORDER BY a.c2" + + sql " set runtime_filter_type = 4; " + qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c3 = b.c3 ORDER BY a.c2" + + sql " set runtime_filter_type = 8; " + qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c3 = b.c3 ORDER BY a.c2" + sql "DROP TABLE ${tbName}" }