Repository navigation
Conversation
ae6b397 to
20f984a
Compare
yonipeleg33
left a comment
There was a problem hiding this comment.
nice work, thanks!
(for the maintainers - i'm a colleague of the author)
i'm mainly concerned about future-proofing this new api
| max: Option<&E::T>, | ||
| distinct_count: Option<u64>, | ||
| ) -> Result<usize> { | ||
| if self.descr.max_rep_level() > 0 { |
There was a problem hiding this comment.
i wonder if we should add support for repetition level now as part of this pr. repeated columns need repetition level data as well as def levels, so the current method signature can't support them.
adding support for it later would mean either a breaking change (changing the signature of this api), or exposing a separate api just for that - neither seem like a good solution to me.
or at least let's decide on the method signature now and we can keep rejecting repeated columns at runtime, just to leave place for future support without a breaking change?
There was a problem hiding this comment.
- I don't think we can support lists with more than one element here. Their first element has rep_level 0 and the rest have 1, so it's never a uniform run.
- Splitting it into two calls (first element, then the rest) doesn't work either, because the second call would start in the middle of a row.
write_batch_internal()disallows that for a reason: a page can be closed between calls, and pages must start at a row boundary. - What we can and I think should support is rows that are a single slot:
null,[[[]]],[[null]], or single-element lists like[42]. That only needs passing rep_level 0 for every slot internally, no API change. If multi-element lists are ever needed, that would be a separate new method, so nothing here would need a breaking change.
There was a problem hiding this comment.
good points. let's wait for the maintainers to weigh in on this
…level Lets callers of the low-level column writer write a run of levels that all share one definition level without materializing a `&[i16]` buffer, using the existing `LevelDataRef::Uniform` path that `ArrowWriter` already uses. Errors on repeated columns and on out-of-range definition levels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…evel tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eef39d4 to
c2f4ba6
Compare
Which issue does this PR close?
Rationale for this change
We write Parquet using the low-level column writer API (
GenericColumnWriter), notArrowWriter. 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'spub(crate)and onlyArrowWritercan use it. This PR adds a small public wrapper on top of it.If you'd rather make
LevelDataRefitself 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 likewrite_batch_with_statisticswithnum_levelscopies ofdef_leveland no rep levels, and callswrite_batch_internalwithLevelDataRef::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:write_batch_with_statisticsgives the same values, def levels, row count and stats (v1 and v2, with runs that split across pages)max_def_level = 0)num_levels = 0Are 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::Uniformpath, 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