github-actions[bot] commented on code in PR #70222:
URL: https://github.com/apache/doris/pull/70222#discussion_r4475161872
##########
be/test/exec/runtime_filter/runtime_filter_wrapper_test.cpp:
##########
@@ -361,6 +370,120 @@ TEST_F(RuntimeFilterWrapperTest, TestMinMaxAssign) {
#undef APPLY_FOR_PRIMITIVE_BASE_TYPE
}
+TEST_F(RuntimeFilterWrapperTest, DateMinMaxAssignPreservesDateType) {
+ RuntimeFilterParams params {.filter_id = 0,
+ .filter_type =
RuntimeFilterType::MINMAX_FILTER,
+ .column_return_type = TYPE_DATE,
+ .null_aware = false};
+ PMergeFilterRequest request;
+ request.set_filter_type(PFilterType::MINMAX_FILTER);
+
request.mutable_minmax_filter()->mutable_min_val()->set_stringval("2012-01-02");
+
request.mutable_minmax_filter()->mutable_max_val()->set_stringval("2012-03-02");
+
+ RuntimeFilterWrapper wrapper(¶ms);
+ ASSERT_TRUE(wrapper.assign(request, nullptr).ok());
+
EXPECT_EQ(static_cast<VecDateTimeValue*>(wrapper.minmax_func()->get_min())->type(),
TIME_DATE);
+
EXPECT_EQ(static_cast<VecDateTimeValue*>(wrapper.minmax_func()->get_max())->type(),
TIME_DATE);
+}
+
+static void check_date_like_minmax_bound(const void* bound, TimeType time_type,
+ PrimitiveType column_type, const
std::string& text,
+ const DataTypePtr& data_type) {
+ const auto* value = static_cast<const VecDateTimeValue*>(bound);
+ EXPECT_EQ(value->type(), time_type);
+ char buffer[30];
+ value->to_string(buffer);
+ EXPECT_EQ(std::string(buffer), text);
+
+ VExprSPtr literal;
+ ASSERT_TRUE(create_literal(data_type, value, literal).ok());
+ ASSERT_TRUE(literal->is_literal());
+ EXPECT_EQ(literal->result_type(), column_type);
+ Field field;
+ static_cast<VLiteral*>(literal.get())->get_column_ptr()->get(0, field);
+ EXPECT_EQ(field.get_type(), column_type);
+}
+
+template <typename Request>
+static void check_date_like_minmax_request(RuntimeFilterWrapper& producer,
+ const RuntimeFilterParams& params,
TimeType time_type,
+ const std::string& min_text, const
std::string& max_text,
+ const DataTypePtr& data_type) {
+ Request request;
+ request.set_filter_type(get_type(params.filter_type));
+ ASSERT_TRUE(producer.to_protobuf(request.mutable_minmax_filter()).ok());
+ RuntimeFilterWrapper receiver(¶ms);
+ ASSERT_TRUE(receiver.assign(request, nullptr).ok());
+ EXPECT_EQ(receiver.get_state(), RuntimeFilterWrapper::State::READY);
+ EXPECT_EQ(receiver.column_type(), params.column_return_type);
+ check_date_like_minmax_bound(receiver.minmax_func()->get_min(), time_type,
+ params.column_return_type, min_text,
data_type);
Review Comment:
[P1] Make the new date min/max round-trip test handle one-sided filters
correctly. `MinNumFunc` serializes only `min_val` and `MaxNumFunc` only
`max_val`, but `check_date_like_minmax_request` always checks both bounds. In
the first `MIN_FILTER` iteration the absent max string is empty, `_assign`
leaves a default `VecDateTimeValue`, and the assertion at this helper fails;
`MAX_FILTER` fails symmetrically for the min side (for both request types).
Restrict the two-bound assertions to `MINMAX_FILTER` or assert only the bound
owned by each one-sided filter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]