Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Feb 25, 2025
1 parent aff1f37 commit 75860ce
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions internal/core/unittest/test_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16136,25 +16136,35 @@ TYPED_TEST(JsonIndexTestFixture, TestJsonIndexUnaryExpr) {
final = ExecuteQueryExpr(plan, seg.get(), N, MAX_TIMESTAMP);
EXPECT_EQ(final.count(), 0);

using DT = std::conditional_t<
std::is_same_v<typename TestFixture::DataType, std::string>,
std::string_view,
typename TestFixture::DataType>;
std::vector<proto::plan::GenericValue> vals;
for (int i = 0; i < 10; ++i) {
using DT = std::conditional_t<
std::is_same_v<typename TestFixture::DataType, std::string>,
std::string_view,
typename TestFixture::DataType>;
int expect_count = 10;
if constexpr (std::is_same_v<DT, bool>) {
proto::plan::GenericValue val;
val.set_bool_val(true);
vals.push_back(val);
val.set_bool_val(false);
vals.push_back(val);
expect_count = N;
} else {
for (int i = 0; i < expect_count; ++i) {
proto::plan::GenericValue val;

auto v = jsons[i].at<DT>(this->json_path).value();
if constexpr (std::is_same_v<DT, bool>) {
val.set_bool_val(v);
} else if constexpr (std::is_same_v<DT, int64_t>) {
val.set_int64_val(v);
} else if constexpr (std::is_same_v<DT, double>) {
val.set_float_val(v);
} else if constexpr (std::is_same_v<DT, std::string_view>) {
val.set_string_val(std::string(v));
auto v = jsons[i].at<DT>(this->json_path).value();
if constexpr (std::is_same_v<DT, int64_t>) {
val.set_int64_val(v);
} else if constexpr (std::is_same_v<DT, double>) {
val.set_float_val(v);
} else if constexpr (std::is_same_v<DT, std::string_view>) {
val.set_string_val(std::string(v));
} else if constexpr (std::is_same_v<DT, bool>) {
val.set_bool_val(i % 2 == 0);
}
vals.push_back(val);
}
vals.push_back(val);
}
term_expr = std::make_shared<expr::TermFilterExpr>(
expr::ColumnInfo(json_fid, DataType::JSON, {this->json_path.substr(1)}),
Expand All @@ -16163,5 +16173,5 @@ TYPED_TEST(JsonIndexTestFixture, TestJsonIndexUnaryExpr) {
plan =
std::make_shared<plan::FilterBitsNode>(DEFAULT_PLANNODE_ID, term_expr);
final = ExecuteQueryExpr(plan, seg.get(), N, MAX_TIMESTAMP);
EXPECT_EQ(final.count(), 10);
EXPECT_EQ(final.count(), expect_count);
}

0 comments on commit 75860ce

Please sign in to comment.