Gabriel39 opened a new pull request, #70875:
URL: https://github.com/apache/doris/pull/70875

   ### Background
   
   Parquet Bloom filters can reject row groups for equality and IN predicates 
before reading data pages. Doris already reads these filters, while OUTFILE, 
writable table functions, Hive and Iceberg sinks use a shared Parquet writer. 
Dictionary filtering cannot replace Bloom filters after dictionary overflow or 
when dictionary encoding is disabled.
   
   ### What problem does this PR solve?
   
   Issue Number: close #70874
   Related PR: None
   PR Type: Feature
   
   Problem Summary:
   
   Users cannot request standard Bloom filters in Parquet files written by 
Doris. Add the runtime session switch `enable_parquet_write_bloom_filter`, 
default false, to enable them through the shared writer. Most of the diff is 
coverage of dictionary modes, physical encodings, query forwarding and failure 
cleanup; the writer also needs a Doris allocation-exception boundary so Bloom 
buffers obey query memory limits. Existing exports keep Bloom output disabled 
unless users opt in.
   
   ### Details
   
   - **Change map:** Production code is +42/-9; tests are +883/-37, plus 37 
generated result lines. The production parts are the shared writer's 
physical-leaf configuration and allocation boundary (+34/-9), the forwarded FE 
session variable (+6), and its optional Thrift field (+2). The tests cover the 
native writer and actual Hive/Iceberg partition writers, FE forwarding, and SQL 
OUTFILE/TVF integration.
   - **Scope:** All eligible physical leaves, including nested leaves, in the 
shared Parquet writer. BOOLEAN is unsupported by the SDK; legacy INT96 is 
excluded. This phase has no column selection, adaptive sizing/folding, FPP/NDV 
controls or separate soft per-file budget. Reader semantics and ORC output are 
unchanged.
   - **Design:** Reuse Arrow 24's standard split-block/XXHASH/uncompressed 
Bloom implementation and physical-type hashing. A single query option avoids 
divergent sink properties; a custom implementation would duplicate SDK encoding 
and ownership. Proposed in #70874, opened with this PR; no prior public design 
discussion is claimed.
   - **Usage:**
   
     ```sql
     SET enable_parquet_write_bloom_filter = true;
     -- Subsequent Parquet OUTFILE, writable TVF, Hive and Iceberg writes use 
the option.
     SET enable_parquet_write_bloom_filter = false;
     ```
   
   - **Default behavior:** False, including requests from older FEs that omit 
the field. Arrow defaults to expected NDV 1,048,576 and FPP 0.05, approximately 
1 MiB per eligible leaf per row group. Filters add hashing work and file size, 
and buffers accumulate across row groups until close, even for all-null 
columns. Allocations use the existing query-accounted Arrow pool and query 
memory limits; enable selectively.
   - **Compatibility:** The new optional query-options field is unused across 
master and supported release branches. Old BEs ignore it and cannot honor 
opt-in until upgraded. Standard optional Parquet metadata remains readable by 
readers that ignore Bloom filters. Existing files, table metadata, images and 
EditLogs need no migration.
   - **Persistence and failure handling:** Existing sink publication, abort and 
retry behavior applies. SDK-owned buffers are released on successful close or 
writer destruction after failure; allocation exceptions become query errors at 
the SDK write boundary. No new persisted FE state or side files are introduced.
   
   ### Testing
   
   - Locally, 60 BE ASAN tests passed: 36 switch/dictionary/version/row-group 
combinations, eight boundary/fault tests and 16 existing writer tests. They 
verify metadata and inserted-value membership, signed zeros/NaN 
payloads/infinities, nullable/binary strings, nested leaves, timestamp/INT96 
and decimal physical bytes, actual Hive/Iceberg writers and page-index 
independence. The Doris allocation-exception test failed before the new catch 
scope and passes with it; allocation and IO failures release tracked memory.
   - Locally, all 16 `SessionVariableParquetWriterTest` FE tests passed, 
including default/explicit forwarding, compact-Thrift round trips, an omitted 
field and invalid values.
   - Locally, `export_p0/test_parquet_write_bloom_filter` passed output 
generation and ordinary replay against a single FE/BE with an S3 emulator: 10 
output scenarios, 200 complete ordered-ID comparisons per run, independent 
Java-Thrift metadata checks, actual dictionary fallback and positive/zero 
Bloom-pruning counters. The result file is generated by the framework.
   - Independently, PyArrow 25.0.1 read 1,024 Doris-exported rows and verified 
decimal, microsecond timestamp, negative-zero sign, nullable string and 
nested-array values. Remote S3/Azure services, full Hive/Iceberg catalog 
transactions and cloud deployment were not exercised locally.
   
   ### Notes for Reviewers
   
   - Build the Bloom properties from a copy of finalized SDK properties: the 
SDK builder moves some options during `build()`.
   - Derive physical paths after converter initialization so nested paths and 
timestamp encodings match the schema actually written.
   - The SQL oracle uses positive zero while files contain negative zero, 
avoiding signed-zero literal folding in the FE while testing reader equality 
semantics.
   
   ### Release note
   
   Add the default-off session variable `enable_parquet_write_bloom_filter` to 
write standard Bloom filters in new Parquet output files. BOOLEAN and legacy 
INT96 columns are excluded. Enable it selectively because each eligible leaf 
and row group adds Bloom memory and file-size overhead.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: Yes (document the switch, physical-type 
exclusions and memory cost in apache/doris-website session-variable 
documentation)
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Implementation, unit and regression tests, and this description.
   - Human review: No human review reported; Codex performed local self-review 
and corrected findings before submission.
   - Prompts: Add a master PR with a switch controlling Parquet Bloom output. 
Provide sufficient unit and regression coverage, and review and correct all 
findings locally before committing and opening the PR.
   


-- 
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]

Reply via email to