Repository navigation
Conversation
|
|
||
| Result<bool> In(const std::shared_ptr<Bound>& expr, | ||
| const BoundSetPredicate::LiteralSet& values) override { | ||
| return AnyMatch(expr, [&](const Literal& item) { return values.contains(item); }); |
There was a problem hiding this comment.
This will return false for NaN.
There was a problem hiding this comment.
Literal uses a custom comparison, so contains can match the same NaN literal in the set, I'm not sure if this is your concern.
| Result<bool> StartsWith(const std::shared_ptr<Bound>& expr, | ||
| const Literal& value) override { | ||
| return AnyMatch(expr, [&](const Literal& item) { | ||
| return std::get<std::string>(item.value()) |
There was a problem hiding this comment.
This can thrown uncaught if the variant is not a string.
There was a problem hiding this comment.
Binder already checks that the term is a string and converts the prefix literal to the same type. ParquetMetricsRowGroupFilter also relies on this and uses std::getstd::string for StartsWith and NotStartsWith.
There was a problem hiding this comment.
After a second check, it seems users can still manually create an invalid BoundPredicate and bypass Binder's checks. But this is rare, we can address this for both filters in a follow-up if needed.
There was a problem hiding this comment.
There is a case where this PR changes what Open does. With a fully dictionary-encoded string column and no footer bounds, the stats filter keeps the group. If a caller supplies an already-bound StartsWith predicate with a non-string prefix, the new dictionary path throws std::bad_variant_access. Could we validate the operands for both prefix operations and return InvalidExpression? This case would also make a focused regression test.
There was a problem hiding this comment.
Fixed. Both StartsWith and NotStartsWith now check the term and prefix types. It returns InvalidExpression for invalid operands.
d1de99e to
a81101f
Compare
| ICEBERG_ARROW_ASSIGN_OR_RETURN(auto file_size, input_->GetSize()); | ||
| if (!column->has_dictionary_page() || start < 4 || end <= start || | ||
| end > file_size) { | ||
| return Invalid("Invalid Parquet dictionary offsets [{}, {}) for field {}", start, |
There was a problem hiding this comment.
Shall we tolerate dictionary offset errors? It should only affect pruning.
There was a problem hiding this comment.
Agreed, changed to return nullptr, I/O errors and dictionary parsing/decoding failures still propagate.
022cfac to
6aa69fe
Compare
| auto encoding = page.encoding() == ::parquet::Encoding::PLAIN_DICTIONARY | ||
| ? ::parquet::Encoding::PLAIN | ||
| : page.encoding(); | ||
| auto decoder = ::parquet::MakeTypedDecoder<DType>(encoding, &column); |
There was a problem hiding this comment.
Please accept only PLAIN and legacy PLAIN_DICTIONARY here and decode both as PLAIN. The generic decoder also accepts data-page encodings such as BYTE_STREAM_SPLIT. Pruning could then silently skip a group whose dictionary page Arrow's column reader would reject.
There was a problem hiding this comment.
Changed this to suggested.
| // Unusable offsets cannot prove that the predicate cannot match. | ||
| return nullptr; | ||
| } | ||
| ICEBERG_ARROW_ASSIGN_OR_RETURN(auto data, input_->ReadAt(start, end - start)); |
There was a problem hiding this comment.
Please check that the dictionary range fits within the column chunk before calling ReadAt. A data-page offset in a later chunk still passes the file-size check, and this call allocates and reads the entire gap. If the range cannot be validated, keep the group.
There was a problem hiding this comment.
Added the chunk size check before ReadAt. Test now covers a data page offset that is inside the file but past the current chunk. The filter keeps the group without reading the dictionary.
| try { | ||
| DictionaryVisitor visitor(manifest, *row_group, field_id_to_column_idx_, input, | ||
| properties, metadata.writer_version()); | ||
| return Visit<bool>(bound_, visitor); |
There was a problem hiding this comment.
Could dictionary evaluation short-circuit AND and OR? Once the left side rules out an AND or retains an OR, visiting the right side can issue a second column read and even fail Open. A two-column test using the recording stream could assert that only the first dictionary is read.
There was a problem hiding this comment.
Great suggestion, dictionary evaluation now short-circuits AND and OR, added a test accordingly.
There was a problem hiding this comment.
Just rebased and switched to the newly added VisitEvaluator.
| Result<bool> AnyMatch(const std::shared_ptr<Bound>& expr, Predicate predicate, | ||
| bool nulls_match = false) { | ||
| auto ref = std::dynamic_pointer_cast<BoundReference>(expr); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto dictionary, GetDictionary(ref)); |
There was a problem hiding this comment.
For predicates where nulls match, could we check the resolved column's null count before fetching its dictionary? If the count is positive or unknown, we already have to keep the group and can skip the read and decode.
There was a problem hiding this comment.
Moved the null count check before the dictionary read.
Use column dictionaries to prune row groups after footer-statistics filtering. Support comparison, set, prefix and NaN predicates, and cache decoded dictionaries within each row group. Keep row groups when encoding metadata cannot rule out plain fallback or field IDs and types cannot be resolved safely. Preserve file-relative row positions and row IDs after pruning. Share physical-value conversion with Parquet metrics and add tests for predicate handling, type promotion, mixed encoding, splits and invalid dictionary pages.
Read the byte range between dictionary_page_offset and data_page_offset instead of loading the full column chunk during planning. Validate the range and keep using Arrow for page decompression. Skip dictionary pruning for encrypted columns so the normal reader handles them. Treat unreadable optional statistics as possible nulls instead of failing the scan. Keep errors for missing or truncated dictionary pages, and explain why rewritten null branches remain inclusive. Add regression tests for planning read ranges with multi-megabyte data pages, invalid offsets, unreadable statistics, signed zeros, and compressed V1/V2 pages. The complete Parquet suite passes all 213 tests, and pre-commit passes.
Use metadata-only projection to keep output-column prefetch out of the dictionary I/O assertion. Add float/double IN and NOT IN coverage with NaN literals.
Validate prefix predicate operands, dictionary page encodings, and column chunk boundaries before pruning. Short-circuit boolean predicates and consult null counts before reading dictionaries for negative predicates.
5652078 to
7d617ae
Compare
Use column dictionaries to prune row groups after footer-statistics filtering. Support comparison, set, prefix and NaN predicates, and cache decoded dictionaries within each row group.
Keep row groups when encoding metadata cannot rule out plain fallback or field IDs and types cannot be resolved safely. Preserve file-relative row positions and row IDs after pruning.
Share physical-value conversion with Parquet metrics and add tests for predicate handling, type promotion, mixed encoding, splits and invalid dictionary pages.