Jefffrey commented on code in PR #22905:
URL: https://github.com/apache/datafusion/pull/22905#discussion_r3407481654
##########
datafusion/expr-common/src/signature.rs:
##########
@@ -1062,12 +1064,37 @@ pub enum Coercion {
desired_type: TypeSignatureClass,
/// Rules for implicit coercion from other types
implicit_coercion: ImplicitCoercion,
+ /// Physical encoding preservation requested by the function.
+ encoding_preservation: EncodingPreservation,
},
}
+/// Controls whether a [`Coercion`] preserves an argument's physical encoding
+/// (e.g. dictionary) instead of materializing it to the coerced value type.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Hash)]
+pub enum EncodingPreservation {
+ /// Do not request preservation of a physical encoding.
+ None,
+ /// Preserve dictionary encoding and coerce only the dictionary values.
+ Dictionary,
+}
Review Comment:
Something to consider is if an enum is best suited for this 🤔
For example, if we want to also include run encoded arrays as well (since
they are similar to dictionaries), would this mean two new variants, one just
for run arrays and one for dictionary + run arrays?
- I don't know if arrow is planning to include any more types of encodings
like this at the moment
So I was also thinking perhaps a bitflag approach (or just a struct with
boolean flags) could be another approach:
```rust
struct Encoding {
preserve_dictionary: bool,
preserve_run: bool,
}
```
But I don't know how common a use case would be to implement preservation
only for dictionaries and not run arrays (or vice versa) so maybe thats
overengineering 🤔
--
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]