lyne7-sc opened a new pull request, #23930:
URL: https://github.com/apache/datafusion/pull/23930

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Follow-up to #22905
   - Related to #19458 and #20935
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   Previously, coercion materialized dictionary-encoded inputs for 
`character_length`, `initcap`, and `reverse`. This lost the encoding and 
evaluated the function for every row instead of once per dictionary value entry.
   
   This PR extends dictionary preservation to these functions.
   
   `character_length` and `reverse` now use `Coercible` signatures to 
explicitly model string inputs and binary-to-string coercion while preserving 
dictionary encoding.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Preserve dictionary encoding for `character_length`, `initcap`, and 
`reverse`.
   - Evaluate only dictionary values while reusing the original keys.
   - Migrate `character_length` and `reverse` from `Uniform` to `Coercible`.
   - Add tests and benchmarks.
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   Yes, covered by SQL logic tests.
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   
   Yes. These functions now preserve dictionary encoding in their output.
   
   `character_length` and `reverse` now accept logical string and binary inputs 
instead of implicitly converting unrelated types to strings.
   
   ## Benchmark
   ```
   group                                                           branch       
                          main
   -----                                                           ------       
                          ----
   dictionary_encoding/string/cardinality_10/character_length      1.00   
218.5±32.62ns        ? ?/sec    31.04     6.8±0.07µs        ? ?/sec
   dictionary_encoding/string/cardinality_10/initcap               1.00    
292.2±4.75ns        ? ?/sec    359.88   105.2±0.91µs        ? ?/sec
   dictionary_encoding/string/cardinality_10/reverse               1.00   
501.6±15.71ns        ? ?/sec    140.60    70.5±1.05µs        ? ?/sec
   dictionary_encoding/string/cardinality_100/character_length     1.00   
307.5±24.93ns        ? ?/sec    21.85     6.7±0.09µs        ? ?/sec
   dictionary_encoding/string/cardinality_100/initcap              1.00  
1486.1±65.36ns        ? ?/sec    70.56   104.9±1.57µs        ? ?/sec
   dictionary_encoding/string/cardinality_100/reverse              1.00  
1410.9±52.69ns        ? ?/sec    49.28    69.5±0.68µs        ? ?/sec
   dictionary_encoding/string/cardinality_1000/character_length    1.00  
1007.4±93.42ns        ? ?/sec    6.64      6.7±0.07µs        ? ?/sec
   dictionary_encoding/string/cardinality_1000/initcap             1.00     
12.8±0.17µs        ? ?/sec    8.41    107.5±8.55µs        ? ?/sec
   dictionary_encoding/string/cardinality_1000/reverse             1.00     
10.5±0.24µs        ? ?/sec    6.56     69.1±0.58µs        ? ?/sec
   dictionary_encoding/string/cardinality_8192/character_length    1.00      
6.6±0.09µs        ? ?/sec    1.02      6.7±0.18µs        ? ?/sec
   dictionary_encoding/string/cardinality_8192/initcap             1.00    
104.2±1.36µs        ? ?/sec    1.00    104.2±1.63µs        ? ?/sec
   dictionary_encoding/string/cardinality_8192/reverse             1.24     
85.4±2.99µs        ? ?/sec    1.00     69.0±0.58µs        ? ?/sec
   ```


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