Skip to content

[ISSUE-789] Add string functions TRIM, LPAD, RPAD#811

Open
candy972023 wants to merge 1 commit into
apache:masterfrom
candy972023:feature/add-trim-lpad-rpad
Open

[ISSUE-789] Add string functions TRIM, LPAD, RPAD#811
candy972023 wants to merge 1 commit into
apache:masterfrom
candy972023:feature/add-trim-lpad-rpad

Conversation

@candy972023

Copy link
Copy Markdown

What does this PR do?

Closes #789

Adds three string scalar functions to GeaFlow DSL:

  • trim(str) — strip leading/trailing whitespace
  • lpad(str, len, pad) — left-pad to target length
  • rpad(str, len, pad) — right-pad to target length

Key design decisions

  • All functions return null on null input (no exception)
  • LPad/RPad handle edge cases: len <= 0 returns empty, empty pad returns original
  • Trim supports both String and BinaryString overloads (consistent with LTrim/RTrim)
  • Behavior matches MySQL / standard SQL

Verification

SELECT trim(' hello '); -- hello
SELECT lpad('hi', 5, 'x'); -- xxxhi
SELECT rpad('hi', 5, 'x'); -- hixxx

Add three scalar string functions to GeaFlow DSL:
- trim(str): strip leading/trailing whitespace
- lpad(str, len, pad): left-pad string to target length
- rpad(str, len, pad): right-pad string to target length

Implementation:
- Trim.java: extends UDF, supports both String and BinaryString
- LPad.java: extends UDF, handles null/empty/truncate edge cases
- RPad.java: extends UDF, handles null/empty/truncate edge cases
- Registered all three in BuildInSqlFunctionTable.java
- Added test SQL + expected output files for each function
- Added StringFunctionTest test class

Closes apache#789
@candy972023

Copy link
Copy Markdown
Author

#789

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.

Add the string functions TRIM / LPAD / RPAD

1 participant