Rich-T-kid opened a new pull request, #27442:
URL: https://github.com/apache/datafusion/pull/27442

   ## Which issue does this PR close?
   
   - Part of #20935.
   
   ## Rationale for this change
   
   `encode` currently materializes dictionary-encoded binary input and encodes 
once per row. For low-cardinality data this repeats the same work for every key 
occurrence.
   
   ## What changes are included in this PR?
   
   `encode` now preserves dictionary encoding through coercion, encodes each 
dictionary value once, and reuses the input keys. Dictionary scalar values keep 
their key type. Oversized retained dictionaries use the existing shared 
compaction guard before their values are transformed.
   
   The existing canonical `dictionary_encoding` benchmark now enables 
dictionary calls for `encode`.
   
   ## What is the testing strategy for this PR?
   
   ```text
   cargo test -p datafusion-functions encoding::inner::tests --lib
   cargo test -p datafusion-sqllogictest --test sqllogictests -- encoding
   cargo clippy -p datafusion-functions --lib --tests -- -D warnings
   cargo check -p datafusion-physical-expr --bench dictionary_encoding
   cargo bench -p datafusion-physical-expr --bench dictionary_encoding -- 
'dictionary_encoding/expression/encode' --warm-up-time 1 --measurement-time 3 
--sample-size 20
   cargo fmt --all -- --check
   git diff --check
   ```
   
   8,192-row cold dictionary results (Criterion medians):
   
   | Cardinality | Dictionary | Current cast-away path | Speedup |
   |---:|---:|---:|---:|
   | 10 | 0.796 us | 256.27 us | 321.9x |
   | 100 | 3.797 us | 261.13 us | 68.8x |
   | 256 | 8.684 us | 256.41 us | 29.5x |
   | 1,000 | 30.139 us | 265.58 us | 8.81x |
   | 8,192 | 234.62 us | 255.34 us | 1.09x |
   
   ## Are there any user-facing changes?
   
   Yes. `encode` returns dictionary-encoded strings for dictionary-encoded 
input instead of materializing a flat string array. The logical values are 
unchanged.
   


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

Reply via email to