imhy opened a new pull request, #9983:
URL: https://github.com/apache/arrow-rs/pull/9983
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax.
-->
- Closes #9982 .
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
## Root cause
`ProjectionMask::without_nested_types` (`parquet/src/arrow/mod.rs:427`)
decides which leaves the predicate cache may cover. The check before this fix
was:
```rust
if root_leaf_counts[root_idx] == 1 && !root.is_list() {
included_leaves.push(leaf_idx);
}
```
PR #8866 added `!root.is_list()` to exclude lists, but a **struct** root
with a single leaf still satisfies the condition and gets cached.
## Fix (1 line)
`parquet/src/arrow/mod.rs:455`:
```diff
- if root_leaf_counts[root_idx] == 1 && !root.is_list() {
+ if root_leaf_counts[root_idx] == 1 && root.is_primitive() {
included_leaves.push(leaf_idx);
}
```
# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are
they covered by existing tests)?
If this PR claims a performance improvement, please include evidence such as
benchmark results.
-->
## Tests added on the branch
### 1. Reproducer integration test
**File:** `parquet/tests/arrow_reader/predicate_cache.rs`
**Name:** `test_async_predicate_on_single_leaf_nullable_struct`
Builds an in-memory Parquet file with `OPTIONAL group b { REQUIRED
BYTE_ARRAY aa (UTF8); }`, writes two rows (parent NULL, parent non-NULL), then
runs the same `IS NULL` row filter through the async reader twice: once with
the default cache, once with `with_max_predicate_cache_size(0)`. It asserts that
- the uncached control yields exactly 1 row (`address` NULL row matches);
- the cached run yields the same row count as the uncached one.
**Pre-fix:** panic at `struct_array.rs:142`.
**Post-fix:** passes (1 row in both cases).
### 2. Unit test
**File:** `parquet/src/arrow/mod.rs` (test module)
**Name:** `test_projection_mask_without_nested_single_leaf_struct`
Directly checks `ProjectionMask::without_nested_types` against a schema with
`OPTIONAL group address { REQUIRED BYTE_ARRAY street; } REQUIRED INT32 id`, for
three input masks (single nested leaf, mixed, all leaves). All three expected
outputs reflect that the struct's leaf is now considered nested.
**Pre-fix:** would return `Some([street_leaf])` for the single-leaf-only
mask.
**Post-fix:** returns `None` for the single-leaf-only mask; returns
`Some([id])` for mixed.
## Verification matrix
| Test | Pre-fix | Post-fix |
|---|---|---|
| `test_projection_mask_without_nested_single_leaf_struct` (new unit) |
would FAIL | PASS |
| `test_async_predicate_on_single_leaf_nullable_struct` (new integration) |
PANIC | PASS |
| `predicate_cache::test_default_read` | PASS | PASS |
| `predicate_cache::test_async_cache_with_filters` | PASS | PASS |
| `predicate_cache::test_sync_cache_with_filters` | PASS | PASS |
| `predicate_cache::test_cache_disabled_with_filters` | PASS | PASS |
| `predicate_cache::test_cache_projection_excludes_nested_columns` | PASS |
PASS |
| `test_projection_mask_without_nested_*` (5 existing) | PASS | PASS |
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]