Skip to content
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
2 changes: 1 addition & 1 deletion be/src/vec/exprs/vexpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, in
break;
}
case TYPE_DATETIMEV2: {
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIMEV2>(data, &node));
THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIMEV2>(data, &node, precision, scale));
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table1 probe:
2011-11-11 11:11:11.123456

table2 build:
2011-11-11 11:11:11.123455

}
case TYPE_DATE: {
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/exprs/vexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ Status create_texpr_literal_node(const void* data, TExprNode* node, int precisio
const auto* origin_value = reinterpret_cast<const DateV2Value<DateTimeV2ValueType>*>(data);
TDateLiteral date_literal;
char convert_buffer[30];
origin_value->to_string(convert_buffer);
origin_value->to_string(convert_buffer, scale);
date_literal.__set_value(convert_buffer);
(*node).__set_date_literal(date_literal);
(*node).__set_node_type(TExprNodeType::DATE_LITERAL);
(*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2));
(*node).__set_type(create_type_desc(PrimitiveType::TYPE_DATETIMEV2, precision, scale));
} else if constexpr (T == TYPE_DECIMALV2) {
const auto* origin_value = reinterpret_cast<const DecimalV2Value*>(data);
(*node).__set_node_type(TExprNodeType::DECIMAL_LITERAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,17 @@
1 2022-01-01 1 2022-01-01
1 2022-01-01 1 2022-01-01

-- !datetime_rf_1_p1 --
2011-11-11 2011-11-11

-- !datetime_rf_1_p2 --
2011-11-11 2011-11-11

-- !datetime_rf_2_p1 --
2011-11-11T11:11:11.123455 2011-11-11T11:11:11.123455

-- !datetime_rf_2_p2 --
2011-11-11T11:11:11.123455 2011-11-11T11:11:11.123455

-- !datetime_rf_3 --

Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,114 @@ suite("test_runtimefilter_on_datev2", "nereids_p0") {
qt_join1 """
SELECT * FROM ${dateTable} a, ${dateV2Table} b WHERE a.date = b.date;
"""

// bug fix
sql "set disable_join_reorder=true;"
sql "set enable_runtime_filter_prune=false;"
sql "set runtime_filter_type='MIN_MAX';"
sql "set runtime_filter_wait_time_ms=10000;"

// test date
sql "drop table if exists dt_rftest_l";
sql "drop table if exists dt_rftest_r";
sql """
CREATE TABLE `dt_rftest_l` (
`k1_date_l` DATEV2
)
DISTRIBUTED BY HASH(`k1_date_l`) buckets 16
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
CREATE TABLE `dt_rftest_r` (
`k1_date_r` DATEV2
)
DISTRIBUTED BY HASH(`k1_date_r`) buckets 16
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
insert into dt_rftest_l values
("2001-11-11 11:11:11.123455"),
("2011-11-11 11:11:11.123455"),
("9999-11-11 11:11:11.123456");
"""
sql """
insert into dt_rftest_r values("2011-11-11 11:11:11.123456");
"""
qt_datetime_rf_1_p1 """
select /*+SET_VAR(parallel_pipeline_task_num=1)*/ * from dt_rftest_l join dt_rftest_r on k1_date_l = k1_date_r order by 1, 2;
"""
qt_datetime_rf_1_p2 """
select /*+SET_VAR(parallel_pipeline_task_num=8)*/ * from dt_rftest_l join dt_rftest_r on k1_date_l = k1_date_r order by 1, 2;
"""

// test datetime
sql "drop table if exists dt_rftest_l";
sql "drop table if exists dt_rftest_r";
sql """
CREATE TABLE `dt_rftest_l` (
`k1_date_l` DATETIMEV2(6)
)
DISTRIBUTED BY HASH(`k1_date_l`) buckets 16
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
CREATE TABLE `dt_rftest_r` (
`k1_date_r` DATETIMEV2(6)
)
DISTRIBUTED BY HASH(`k1_date_r`) buckets 16
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
insert into dt_rftest_l values
("2001-11-11 11:11:11.123455"),
("2011-11-11 11:11:11.123455"),
("9999-11-11 11:11:11.123455");
"""
sql """
insert into dt_rftest_r values("2011-11-11 11:11:11.123455");
"""
// RF is different with parallel_pipeline_task_num=1 and parallel_pipeline_task_num=2
qt_datetime_rf_2_p1 """
select /*+SET_VAR(parallel_pipeline_task_num=1)*/ * from dt_rftest_l join dt_rftest_r on k1_date_l = k1_date_r order by 1, 2;
"""
qt_datetime_rf_2_p2 """
select /*+SET_VAR(parallel_pipeline_task_num=8)*/ * from dt_rftest_l join dt_rftest_r on k1_date_l = k1_date_r order by 1, 2;
"""

sql "drop table if exists dt_rftest_l";
sql "drop table if exists dt_rftest_r";
sql """
CREATE TABLE `dt_rftest_l` (
`k1_date` DATEV2
)
DISTRIBUTED BY HASH(`k1_date`)
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
CREATE TABLE `dt_rftest_r` (
`k1_char` varchar(64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rftest_r (string) ---> build hash table (datetimev2(0)) ---> min max (9999-12-31 23:59:59:999999) --->

consumer: liternal (9999-12-31 23:59:59:999999) (datetimev2(0))

)
DISTRIBUTED BY HASH(`k1_char`)
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
)
"""

sql """ insert into dt_rftest_l values
("9999-12-31 23:59:59");
"""
sql """ insert into dt_rftest_r values
("9999-12-31 23:59:59.999999");
"""
qt_datetime_rf_3 """ select * from dt_rftest_l join dt_rftest_r on k1_date = k1_char order by 1, 2"""
}