[
https://issues.apache.org/jira/browse/ASTERIXDB-3615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17955515#comment-17955515
]
ASF subversion and git services commented on ASTERIXDB-3615:
------------------------------------------------------------
Commit 92a2d2bf12ef6023349c229e67c11955a24bac0c in asterixdb's branch
refs/heads/master from Janhavi Tripurwar
[ https://gitbox.apache.org/repos/asf?p=asterixdb.git;h=92a2d2bf12 ]
[ASTERIXDB-3615][FUN]: lpad and rpad func
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Implements the LPAD(input_str, length, pad_char) function
for left-padding strings to a target length using the specified pad_str.
- Truncates input if longer than the target length
- Supports Unicode input_str and pad_str.
- Implements the RPAD(input_str, length, pad_char) function
for right-padding strings to a target codepoint length using the pad_str.
Ext-ref: MB-67008
Change-Id: Ia74279fbbe9d23538c057cbbae9538cb219da1f2
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19828
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Reviewed-by: Ali Alsuliman <[email protected]>
> Implement LPAD and RPAD Function
> --------------------------------
>
> Key: ASTERIXDB-3615
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-3615
> Project: Apache AsterixDB
> Issue Type: Task
> Components: COMP - Compiler, FUN - Functions, RT - Runtime
> Reporter: Janhavi Tripurwar
> Assignee: Janhavi Tripurwar
> Priority: Major
> Labels: triaged
>
> Add {{LPAD}} *{{}}* {{and RPAD}}Β string functions to support left and right
> padding up to a target codepoint length. Functions must handle Unicode
> characters correctly.
> {{*LPAD(input_str, length, pad_str)*}}
> Returns a new string by prepending {{pad_str}} to {{input_str}} until it
> reaches {{length}} Unicode codepoints. If {{input_str}} exceeds
> {{{}length{}}}, it is truncated from the right.
> Example:
> {code:java}
> select lpad('asterix', 11, '$&^'), lpad('π©βπ©βπ§β', 2, '$'), lpad('π©βπ©βπ§β', 10,
> 'π©βπ©βπ§βπ¦'), lpad(null, 4, '%%');{code}
> Result:
> {code:java}
> { $1: "$&^$asterix", $2: "π©β", $3: "π©βπ©βπ©βπ©βπ§β", $4: null }{code}
> {{*RPAD(input_str, length, pad_str)*}}
> Returns a new string by appending {{pad_str}} to {{input_str}} until it
> reaches {{length}} Unicode codepoints. If {{input_str}} exceeds
> {{{}length{}}}, it is truncated from the right.
> Example:
> {code:java}
> select rpad('asterix', 11, '$&^'), rpad('π©βπ©βπ§β', 2, '$'), rpad('π©βπ©βπ§β', 10,
> 'π©βπ©βπ§βπ¦'), rpad(null, 4, '%%'){code}
> {code:java}
> { $1: "asterix$&^$", $2: "π©β", $3: "π©βπ©βπ§βπ©βπ©β", $4: null }{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)