eliduvid opened a new pull request, #12507:
URL: https://github.com/apache/arrow-rs/pull/12507

   # Which issue does this PR close?
   
   - Relates to #9731
   
   # Rationale for this change
   
   We write Parquet using the low-level column writer API 
(`GenericColumnWriter`), not `ArrowWriter`. A lot of our columns are mostly 
empty, with long runs of nulls and runs of values.
   
   With the public API we have to pass a `&[i16]` of def levels for every row, 
even when it's 10k zeros in a row. So for a while we've kept a small fork that 
adds a method for "the next N rows all have def level X".
   
   While looking at upgrading to 60 I noticed #9831 added 
`LevelDataRef::Uniform`, which is pretty much the same thing, but it's 
`pub(crate)` and only `ArrowWriter` can use it. This PR adds a small public 
wrapper on top of it.
   
   If you'd rather make `LevelDataRef` itself public instead, that works for us 
too.
   
   # What changes are included in this PR?
   
   Adds `GenericColumnWriter::write_batch_with_uniform_def_level(values, 
def_level, num_levels, min, max, distinct_count)`. It works like 
`write_batch_with_statistics` with `num_levels` copies of `def_level` and no 
rep levels, and calls `write_batch_internal` with `LevelDataRef::Uniform`.
   
   It returns an error for repeated (list) columns and for def levels outside 
`0..=max_def_level`.
   
   # Are these changes tested?
   
   Yes, new tests in `column/writer/mod.rs`:
   - writing the same runs with the new method and with 
`write_batch_with_statistics` gives the same values, def levels, row count and 
stats (v1 and v2, with runs that split across pages)
   - required column (`max_def_level = 0`)
   - `num_levels = 0`
   - errors: repeated column, out-of-range def level, not enough values
   
   # Are there any significant user-facing changes?
   
   No. It only adds a new method, nothing existing changes.
   
   # AI usage disclosure
   
   I used Claude Code to find the existing `LevelDataRef::Uniform` path, and it 
drafted the method, the tests and this description. I reviewed all of it, and 
the method matches what we've been running in our fork.
   
   cc @HippoBaro since you did #9831
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01A2hCiXPtZHvFFqsYFv3hB1
   


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

Reply via email to