Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit a031520

Browse files
committed
Avoid null comparison for non-nullable args.
Signed-off-by: ienkovich <[email protected]>
1 parent 734744b commit a031520

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

omniscidb/QueryEngine/RowFuncBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,11 @@ llvm::Value* RowFuncBuilder::convertNullIfAny(const hdk::ir::Type* arg_type,
730730
}
731731
}
732732
if (need_conversion) {
733+
// Boolean values can be represented as a i1 LLVM values and cannot be NULLs.
734+
if (target->getType()->isIntegerTy(1)) {
735+
return executor_->cgen_state_->castToTypeIn(target_to_cast, chosen_bytes << 3);
736+
}
737+
733738
auto cmp = arg_type->isFloatingPoint() ? LL_BUILDER.CreateFCmpOEQ(target, arg_null)
734739
: LL_BUILDER.CreateICmpEQ(target, arg_null);
735740
return LL_BUILDER.CreateSelect(

omniscidb/Tests/QueryBuilderTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5302,6 +5302,25 @@ TEST_F(Issue355, Reproducer) {
53025302
compare_res_data(res, std::vector<int64_t>({1}), std::vector<int64_t>({12}));
53035303
}
53045304

5305+
class Issue513 : public TestSuite {
5306+
protected:
5307+
static void SetUpTestSuite() {
5308+
createTable("test_513", {{"A", ctx().int64()}});
5309+
insertCsvValues("test_513", "1\n2\n3");
5310+
}
5311+
5312+
static void TearDownTestSuite() { dropTable("test_513"); }
5313+
};
5314+
5315+
TEST_F(Issue513, Reproducer) {
5316+
QueryBuilder builder(ctx(), getStorage(), configPtr());
5317+
auto scan = builder.scan("test_513");
5318+
auto proj = scan.proj(scan.ref("A").isNull());
5319+
auto dag = proj.agg(std::vector<std::string>(), {proj.ref(0).count()}).finalize();
5320+
auto res = runQuery(std::move(dag));
5321+
compare_res_data(res, std::vector<int32_t>({3}));
5322+
}
5323+
53055324
TEST_F(QueryBuilderTest, RunOnResult) {
53065325
QueryBuilder builder(ctx(), schema_mgr_, configPtr());
53075326

0 commit comments

Comments
 (0)