Skip to content

Commit 60448b8

Browse files
authored
fix: bugfix for predicate batch reader not check predicate nullptr (#98)
1 parent a6fe3b4 commit 60448b8

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/paimon/common/reader/predicate_batch_reader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ PredicateBatchReader::PredicateBatchReader(std::unique_ptr<BatchReader>&& reader
4848
Result<std::unique_ptr<PredicateBatchReader>> PredicateBatchReader::Create(
4949
std::unique_ptr<BatchReader>&& reader, const std::shared_ptr<Predicate>& predicate,
5050
const std::shared_ptr<MemoryPool>& pool) {
51+
if (!predicate) {
52+
return Status::Invalid("create predicate batch reader failed. predicate is nullptr");
53+
}
5154
auto predicate_filter = std::dynamic_pointer_cast<PredicateFilter>(predicate);
5255
if (!predicate_filter) {
5356
return Status::Invalid(

src/paimon/common/reader/predicate_batch_reader_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,11 @@ TEST_F(PredicateBatchReaderTest, TestFullAndEmptyCase) {
188188
}
189189
}
190190

191+
TEST_F(PredicateBatchReaderTest, TestInvalidInput) {
192+
auto data_array = PrepareArray(8);
193+
auto reader = std::make_unique<MockFileBatchReader>(data_array, data_type_, /*batch_size=*/10);
194+
ASSERT_NOK_WITH_MSG(PredicateBatchReader::Create(std::move(reader), nullptr, GetDefaultPool()),
195+
"create predicate batch reader failed. predicate is nullptr");
196+
}
197+
191198
} // namespace paimon::test

src/paimon/core/operation/abstract_split_read.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ std::unordered_map<std::string, DeletionFile> AbstractSplitRead::CreateDeletionF
123123

124124
Result<std::unique_ptr<BatchReader>> AbstractSplitRead::ApplyPredicateFilterIfNeeded(
125125
std::unique_ptr<BatchReader>&& reader, const std::shared_ptr<Predicate>& predicate) const {
126-
if (!context_->EnablePredicateFilter()) {
126+
if (!context_->EnablePredicateFilter() || predicate == nullptr) {
127127
return std::move(reader);
128128
}
129129
return PredicateBatchReader::Create(std::move(reader), predicate, pool_);

0 commit comments

Comments
 (0)