Skip to content

Commit c8b03ef

Browse files
authored
Fix bug in discardNull (#5927)
* Fix bug in discardNull * ci: auto code format --------- Co-authored-by: CI Bot <[email protected]>
1 parent c2a260e commit c8b03ef

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

src/common/vector/value_vector.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,24 @@ uint32_t ValueVector::countNonNull() const {
5858
bool ValueVector::discardNull(ValueVector& vector) {
5959
if (vector.hasNoNullsGuarantee()) {
6060
return true;
61+
}
62+
auto selectedPos = 0u;
63+
if (vector.state->getSelVector().isUnfiltered()) {
64+
auto buffer = vector.state->getSelVectorUnsafe().getMutableBuffer();
65+
for (auto i = 0u; i < vector.state->getSelVector().getSelSize(); i++) {
66+
buffer[selectedPos] = i;
67+
selectedPos += !vector.isNull(i);
68+
}
69+
vector.state->getSelVectorUnsafe().setToFiltered();
6170
} else {
62-
auto selectedPos = 0u;
63-
if (vector.state->getSelVector().isUnfiltered()) {
64-
auto buffer = vector.state->getSelVectorUnsafe().getMutableBuffer();
65-
for (auto i = 0u; i < vector.state->getSelVector().getSelSize(); i++) {
66-
buffer[selectedPos] = i;
67-
selectedPos += !vector.isNull(i);
68-
}
69-
vector.state->getSelVectorUnsafe().setToFiltered();
70-
} else {
71-
for (auto i = 0u; i < vector.state->getSelVector().getSelSize(); i++) {
72-
auto pos = vector.state->getSelVector()[i];
73-
vector.state->getSelVectorUnsafe()[i] = pos;
74-
selectedPos += !vector.isNull(pos);
75-
}
71+
for (auto i = 0u; i < vector.state->getSelVector().getSelSize(); i++) {
72+
auto pos = vector.state->getSelVector()[i];
73+
vector.state->getSelVectorUnsafe()[selectedPos] = pos;
74+
selectedPos += !vector.isNull(pos);
7675
}
77-
vector.state->getSelVectorUnsafe().setSelSize(selectedPos);
78-
return selectedPos > 0;
7976
}
77+
vector.state->getSelVectorUnsafe().setSelSize(selectedPos);
78+
return selectedPos > 0;
8079
}
8180

8281
bool ValueVector::setNullFromBits(const uint64_t* srcNullEntries, uint64_t srcOffset,

src/processor/operator/hash_join/join_hash_table.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ void JoinHashTable::probe(const std::vector<ValueVector*>& keyVectors, ValueVect
136136
return;
137137
}
138138
hashSelVec.setSelSize(keyVectors[0]->state->getSelVector().getSelSize());
139-
function::VectorHashFunction::computeHash(*keyVectors[0], keyVectors[0]->state->getSelVector(),
139+
VectorHashFunction::computeHash(*keyVectors[0], keyVectors[0]->state->getSelVector(),
140140
hashVector, hashSelVec);
141141
for (auto i = 1u; i < keyVectors.size(); i++) {
142142
hashSelVec.setSelSize(keyVectors[i]->state->getSelVector().getSelSize());
143-
function::VectorHashFunction::computeHash(*keyVectors[i],
144-
keyVectors[i]->state->getSelVector(), *tmpHashResultVector, hashSelVec);
145-
function::VectorHashFunction::combineHash(hashVector, hashSelVec, *tmpHashResultVector,
146-
hashSelVec, hashVector, hashSelVec);
143+
VectorHashFunction::computeHash(*keyVectors[i], keyVectors[i]->state->getSelVector(),
144+
*tmpHashResultVector, hashSelVec);
145+
VectorHashFunction::combineHash(hashVector, hashSelVec, *tmpHashResultVector, hashSelVec,
146+
hashVector, hashSelVec);
147147
}
148148
for (auto i = 0u; i < hashSelVec.getSelSize(); i++) {
149149
KU_ASSERT(i < DEFAULT_VECTOR_CAPACITY);

test/test_files/issue/issue.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,3 +592,22 @@ Copy exception: Unable to find primary key value 1.
592592
-STATEMENT match (a:Test1), (b:Test2) create (a)-[e:Xyz]->(b);
593593
---- error
594594
Binder exception: Cannot find a valid label in e that connects Test1 and Test2.
595+
596+
-CASE 5893
597+
598+
-STATEMENT create node table Account(id serial primary key, service string, name string);
599+
---- ok
600+
-STATEMENT create (a:Account {service: 'A', name: 'alice'});
601+
---- ok
602+
-STATEMENT create (a:Account {service: 'A', name: null});
603+
---- ok
604+
-STATEMENT create (a:Account {service: 'B', name: null});
605+
---- ok
606+
-STATEMENT create (a:Account {service: 'B', name: 'alice'});
607+
---- ok
608+
-STATEMENT match (a_account:Account {service: 'A'})
609+
match (b_account:Account {service: 'B'})
610+
where a_account.name = b_account.name
611+
return a_account.name;
612+
---- 1
613+
alice

0 commit comments

Comments
 (0)