lyne7-sc opened a new pull request, #24100:
URL: https://github.com/apache/datafusion/pull/24100
## 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.
-->
- Followup to #23930
- 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.
Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->
Previously, coercion materialized dictionary-encoded inputs for `btrim`,
`ltrim`, and `rtrim`. 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 trim functions.
## 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 `btrim`, `ltrim`, and `rtrim`.
- 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 slt
## 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.
-->
These functions now preserve dictionary encoding in their output.
### Benchmarks
```
group optimize
main
----- --------------
---------
dictionary_encoding/string/cardinality_10/btrim 1.00 286.8±13.36ns
? ?/sec 137.69 39.5±4.56µs ? ?/sec
dictionary_encoding/string/cardinality_10/ltrim 1.00 282.3±4.68ns
? ?/sec 151.48 42.8±8.96µs ? ?/sec
dictionary_encoding/string/cardinality_10/rtrim 1.00 278.8±13.01ns
? ?/sec 119.91 33.4±3.85µs ? ?/sec
dictionary_encoding/string/cardinality_100/btrim 1.00 718.4±4.53ns
? ?/sec 51.89 37.3±0.92µs ? ?/sec
dictionary_encoding/string/cardinality_100/ltrim 1.00 696.4±6.33ns
? ?/sec 54.02 37.6±1.68µs ? ?/sec
dictionary_encoding/string/cardinality_100/rtrim 1.00 659.2±6.91ns
? ?/sec 55.33 36.5±6.84µs ? ?/sec
dictionary_encoding/string/cardinality_1000/btrim 1.00 4.5±0.03µs
? ?/sec 9.71 43.3±8.35µs ? ?/sec
dictionary_encoding/string/cardinality_1000/ltrim 1.00 4.2±0.04µs
? ?/sec 9.06 37.8±4.46µs ? ?/sec
dictionary_encoding/string/cardinality_1000/rtrim 1.00 3.9±0.05µs
? ?/sec 8.69 33.9±1.96µs ? ?/sec
dictionary_encoding/string/cardinality_8192/btrim 1.01 37.4±1.64µs
? ?/sec 1.00 37.1±0.68µs ? ?/sec
dictionary_encoding/string/cardinality_8192/ltrim 1.00 34.7±1.75µs
? ?/sec 1.01 35.1±1.55µs ? ?/sec
dictionary_encoding/string/cardinality_8192/rtrim 1.00 31.9±1.18µs
? ?/sec 1.17 37.3±5.68µ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]