xylaaaaa opened a new pull request, #71083:
URL: https://github.com/apache/doris/pull/71083
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Querying `parquet_meta` in `parquet_metadata` mode on Parquet files
containing unannotated `BYTE_ARRAY` columns with statistics (for example plain
binary columns or Parquet Variant `metadata`/`value` leaves) aborts BE with an
`assert_cast` mismatch between `ColumnString` and `ColumnVarbinary`, even when
the query does not project any statistics columns (such as `SELECT
path_in_schema FROM parquet_meta(...) ORDER BY column_id`).
Root cause:
1. `ParquetMetadataReader::_append_file_rows` parses footers with
`enable_mapping_varbinary = true`, mapping unannotated `BYTE_ARRAY` columns to
`TYPE_VARBINARY`. `PhysicalToLogicalConverter::get_converter` returns
`ConsistentPhysicalConverter` (`is_consistent() == true`) for `(BYTE_ARRAY,
TYPE_VARBINARY)`. However, `parquet_utils::decode_statistics_value`
unconditionally created a `ColumnString` for `tparquet::Type::BYTE_ARRAY` and
passed it directly to `DataTypeVarbinary::to_string`, whose
`DataTypeVarbinarySerDe::to_string` executes `assert_cast<const
ColumnVarbinary&>(column)` and aborts.
2. `ParquetMetadataModeHandler::append_rows` passed
`decode_statistics_value(...)` directly as an argument to
`insert_if_requested(...)`. Because C++ evaluates function arguments before
invoking the lambda, `decode_statistics_value` ran eagerly for all four
statistics columns (`stats_min`, `stats_max`, `stats_min_value`,
`stats_max_value`) even when none of them were requested in the query
projection.
Fix:
1. In `parquet_utils::decode_statistics_value`, construct `ColumnVarbinary`
when a `BYTE_ARRAY` field maps to `PrimitiveType::TYPE_VARBINARY`, while
keeping `ColumnString` for UTF-8/STRING and `BYTE_ARRAY`-backed DECIMAL columns.
2. In `ParquetMetadataModeHandler::append_rows`, gate `path_map`
construction, schema lookup, and `decode_statistics_value` calls on
`_slot_pos[idx] >= 0` before decoding statistics.
3. Add BE unit tests in `ParquetUtilsTest` and `ParquetMetadataReaderTest`
covering unannotated `BYTE_ARRAY` (`VARBINARY`), annotated UTF-8 `STRING`,
`BYTE_ARRAY`-backed `DECIMAL`, and `parquet_metadata` scans both with and
without statistics columns projected.
### Release note
Fix BE crash in `parquet_meta` (`parquet_metadata` mode) when reading
Parquet files with unannotated `BYTE_ARRAY` (`VARBINARY`) column statistics,
and skip decoding statistics columns that are not projected.
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [x] Unit Test (added `ParquetUtilsTest.DecodeStatisticsValueByteArray`
and `ParquetMetadataReaderTest.*`; verified
`build-support/check-build-hygiene.sh` and `clang-format` v16 locally; awaiting
CI / manual BE UT execution)
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test.
- Behavior changed:
- [x] No.
- [ ] Yes.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]