Skip to content

Commit

Permalink
[Bug] Fix the empty values when runtime filter is LOCAL mode (#7794)
Browse files Browse the repository at this point in the history
close #7798
  • Loading branch information
elsa0520 authored Jul 12, 2023
1 parent c6944e7 commit 8404eb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
14 changes: 14 additions & 0 deletions dbms/src/Flash/tests/gtest_runtime_filter_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ try
{{"k1", TiDB::TP::TypeLong}, {"k2", TiDB::TP::TypeLong}},
{toNullableVec<Int32>("k1", {2, 2, 3, 4}),
toNullableVec<Int32>("k2", {2, 2, 3, 4})});
context.addExchangeReceiver("right_empty_table",
{{"k1", TiDB::TP::TypeLong}, {"k2", TiDB::TP::TypeLong}});

WRAP_FOR_RF_TEST_BEGIN
{
Expand All @@ -81,6 +83,18 @@ try
Expect expect{{"table_scan_0", {2, enable_pipeline ? concurrency : 1}}, {"exchange_receiver_1", {4, concurrency}}, {"Join_2", {3, concurrency}}};
testForExecutionSummary(request, expect);
}

{
// issue #45300
// test empty build side, with runtime filter, table_scan_0 return 0 rows
mock::MockRuntimeFilter rf(1, col("k1"), col("k1"), "exchange_receiver_1", "table_scan_0");
auto request = context
.scan("test_db", "left_table", std::vector<int>{1})
.join(context.receive("right_empty_table"), tipb::JoinType::TypeInnerJoin, {col("k1")}, rf)
.build(context);
Expect expect{{"table_scan_0", {0, enable_pipeline ? concurrency : 1}}, {"exchange_receiver_1", {0, concurrency}}, {"Join_2", {0, concurrency}}};
testForExecutionSummary(request, expect);
}
WRAP_FOR_RF_TEST_END
}
CATCH
Expand Down
17 changes: 12 additions & 5 deletions dbms/src/Storages/DeltaMerge/Filter/In.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class In : public RSOperator
: attr(attr_)
, values(values_)
{
if (unlikely(values.empty()))
throw Exception("Unexpected empty values");
}

String name() override { return "in"; }
Expand All @@ -41,15 +39,24 @@ class In : public RSOperator
String toDebugString() override
{
String s = R"({"op":")" + name() + R"(","col":")" + attr.col_name + R"(","value":"[)";
for (auto & v : values)
s += "\"" + applyVisitor(FieldVisitorToDebugString(), v) + "\",";
s.pop_back();
if (!values.empty())
{
for (auto & v : values)
s += "\"" + applyVisitor(FieldVisitorToDebugString(), v) + "\",";
s.pop_back();
}
return s + "]}";
};


RSResult roughCheck(size_t pack_id, const RSCheckParam & param) override
{
// If values is empty (for example where a in ()), all packs will not match.
// So return none directly.
if (values.empty())
{
return RSResult::None;
}
GET_RSINDEX_FROM_PARAM_NOT_FOUND_RETURN_SOME(param, attr, rsindex);
// TODO optimize for IN
RSResult res = rsindex.minmax->checkEqual(pack_id, values[0], rsindex.type);
Expand Down

0 comments on commit 8404eb7

Please sign in to comment.