Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix the empty values when runtime filter is LOCAL mode #7794

Merged
merged 3 commits into from
Jul 12, 2023
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
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