Repository navigation
Conversation
…ctionary fallback Preserve the resolved non-dictionary column encoding (`fallback_encoding_`) in `ColumnWriter::Make` when dictionary encoding is enabled, and instantiate `fallback_encoding_` instead of hardcoded `Encoding::PLAIN` in `TypedColumnWriterImpl::FallbackToPlainEncoding()`. Also validate fallback encodings upfront on `ColumnWriter` creation when dictionary encoding is enabled, and gate `CheckDictionarySizeLimit()` on `check_page` for repeated columns when pages change on record boundaries.
|
|
Member
|
Closing as this didn't even bother using the standard PR template. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
When dictionary encoding is enabled on a column (
enable_dictionary(), the default),WriterProperties::Builder::encoding(...)rejectsPLAIN_DICTIONARYandRLE_DICTIONARYwith"Can't use dictionary encoding as fallback encoding", indicating that the configured encoding is intended as the fallback encoding. However:ColumnWriter::Makeoverwroteencodingwithproperties->dictionary_index_encoding()whenuse_dictionarywas true without preserving the resolved non-dictionary encoding, andTypedColumnWriterImpl::FallbackToPlainEncoding()hardcodedEncoding::PLAIN(see also [Parquet] Make default fallback encoding choice smarter #40636). As a result, configuring e.g.DELTA_LENGTH_BYTE_ARRAY,DELTA_BYTE_ARRAY,DELTA_BINARY_PACKED, orBYTE_STREAM_SPLITon a dictionary-enabled column was ignored whenever the column overfloweddictionary_pagesize_limitor fell back on varyingarrow::DictionaryArraychunks.(physical_type, encoding)pairs on dictionary-enabled columns were not validated upfront onColumnWritercreation, only failing at runtime if the column happened to overflow its dictionary.CheckDictionarySizeLimit()was called after every batch inWriteBatchInternal,WriteBatchSpacedInternal, andTypedColumnWriterImpl<ByteArrayType>::WriteArrowDenseeven whencheck_page == false(mid-record on a repeated column whenpages_change_on_record_boundaries()is active), which could flush buffered dictionary pages mid-record.What changes are included in this PR?
fallback_encodinginColumnWriter::Makebefore switchingencodingtoproperties->dictionary_index_encoding(), and usefallback_encoding_inTypedColumnWriterImpl::FallbackToPlainEncoding().fallback_encodingupfront inTypedColumnWriterImplwhenuse_dictionaryis true so unsupported(physical_type, fallback_encoding)combinations throwParquetExceptionimmediately uponColumnWritercreation.CheckDictionarySizeLimit()oncheck_page || descr_->max_repetition_level() == 0 || rep_levels == nullptrinWriteBatchInternal,WriteBatchSpacedInternal, andTypedColumnWriterImpl<ByteArrayType>::WriteArrowDenseso dictionary fallback on repeated columns only flushes at record boundaries whenpages_change_on_record_boundaries()is true.WriterProperties::Builder::encoding(...)docstrings incpp/src/parquet/properties.h.Are these changes tested?
Yes, added unit tests in
cpp/src/parquet/column_writer_test.ccandcpp/src/parquet/properties_test.cccovering:PARQUET_1_0(PLAIN_DICTIONARY->PLAIN) andPARQUET_2_6(RLE_DICTIONARY-> configured fallback encoding) dictionary page and data page encodings.DELTA_LENGTH_BYTE_ARRAY,DELTA_BYTE_ARRAY,DELTA_BINARY_PACKED, andBYTE_STREAM_SPLITacrossWriteTable(including varyingDictionaryArraychunks andSizeStatistics),WriteBatch, andWriteBatchSpaced.list<utf8>dictionary overflow across mid-record batch splits withenable_write_page_index()verifying record-alignedOffsetIndexpage locations.Are there any user-facing changes?
Yes: columns with both dictionary encoding enabled and an explicit non-dictionary
WriterProperties::Builder::encoding(...)now fall back to that configured encoding instead ofEncoding::PLAINwhen the dictionary page size limit is reached, and incompatible fallback encodings on dictionary-enabled columns now fail immediately when creating theColumnWriter.AI Transparency Statement