From 50fac300d3ce3de943a6c0b6f559eeb546c7d70e Mon Sep 17 00:00:00 2001 From: Daniel Hunte Date: Thu, 21 Nov 2024 15:51:13 -0800 Subject: [PATCH] fix(joins): Strengthen nullptr check for null aware hash joins with filters Summary: The mayHaveNulls() method sometimes returns true when there are in fact no nulls. This change will make sure that a nullptr isn't passed to memcpy. Differential Revision: D66333546 --- velox/exec/HashProbe.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/velox/exec/HashProbe.cpp b/velox/exec/HashProbe.cpp index f8a820529fe88..65200c624b78b 100644 --- a/velox/exec/HashProbe.cpp +++ b/velox/exec/HashProbe.cpp @@ -1212,11 +1212,12 @@ void HashProbe::prepareFilterRowsForNullAwareJoin( for (auto& projection : filterInputProjections_) { filterInputColumnDecodedVector_.decode( *filterInput->childAt(projection.outputChannel), filterInputRows_); - if (filterInputColumnDecodedVector_.mayHaveNulls()) { + if (const uint64_t* nulls = + filterInputColumnDecodedVector_.nulls(&filterInputRows_)) { SelectivityVector nullsInActiveRows(numRows); memcpy( nullsInActiveRows.asMutableRange().bits(), - filterInputColumnDecodedVector_.nulls(&filterInputRows_), + nulls, bits::nbytes(numRows)); // All rows that are not active count as non-null here. bits::orWithNegatedBits(