feat: add RunEndEncoded variant to ScalarValue enum #18571
Draft
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.
Which issue does this PR close?
Rationale for this change
This PR addresses the missing
RunEndEncodedvariant in theScalarValueenum, which is essential for proper type coercion and operations involving RunEndEncoded arrays. RunEndEncoded (REE) is an Arrow data type for run-length encoding of repeated values, and without properScalarValuesupport, operations involving REE arrays would fail to work correctly.The implementation follows the existing patterns in the DataFusion codebase and ensures compatibility with the Arrow specification for RunEndEncoded arrays.
What changes are included in this PR?
Added
RunEndEncodedvariant toScalarValueenum indatafusion/common/src/scalar/mod.rsRunEndEncoded(Arc<RunEndEncodedScalar>)Implemented
RunEndEncodedScalarstruct with required trait implementations:PartialEqandEqfor value equality comparisonsHashfor hash-based operationsPartialOrdfor ordering operationsDebugandClonefor debugging and copyingUpdated existing trait implementations to handle the new variant:
PartialEqforScalarValuePartialOrdforScalarValueHashforScalarValueAdded support for null values in
try_new_null()methodComprehensive test coverage with unit tests covering:
Are these changes tested?
Yes, this PR includes comprehensive test coverage:
RunEndEncodedScalarcovering all trait implementationsScalarValueenum operations with the new variantAll tests pass successfully and the implementation maintains compatibility with existing functionality.
Are there any user-facing changes?
Yes, this PR introduces user-facing changes by extending the public API:
New Public API:
ScalarValue::RunEndEncoded(Arc<RunEndEncodedScalar>)- New enum variantRunEndEncodedScalarstruct with publicrun_endsandvaluesfieldsUser Impact:
No Breaking Changes:
The changes follow DataFusion's API evolution guidelines and are fully backward compatible.