Skip to content

[spark] Introduce TrimTransform for trim/ltrim/rtrim functions to pushdown#7273

Merged
JingsongLi merged 6 commits intoapache:masterfrom
xuzifu666:trim_support
Feb 12, 2026
Merged

[spark] Introduce TrimTransform for trim/ltrim/rtrim functions to pushdown#7273
JingsongLi merged 6 commits intoapache:masterfrom
xuzifu666:trim_support

Conversation

@xuzifu666
Copy link
Member

Purpose

Linked issue: close #xxx

The trim function are frequently used. This PR supports trim/ltrim/rtrim functions pushdown in Spark side.

Note the automatic conversion in Spark, as follows:
trim(leading 'abc' from b) => ltrim('abc', b)
trim(tailing 'abc' from b) => rtrim('abc', b)
trim(both 'abc' from b) => trim('abc', b)

Tests

API and Format

Documentation

Generative AI tooling

}

public static String trim(String value, String charsToTrim) {
if (value == null || charsToTrim == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless if, remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminder,Done.


public static final String RTRIM = "RTRIM";

private final String trimWay;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create an enum Flag in this class. And values LEADING, TRAILING, BOTH.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@JingsongLi
Copy link
Contributor

+1

@JingsongLi JingsongLi merged commit 213f75c into apache:master Feb 12, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants