Skip to content

Conversation

@jpedroantunes
Copy link
Contributor

Implement LPAD and RPAD functions for string input values.

  • LPAD([string] basetext, [number] x, [optional string] padtext)
  • RPAD([string] basetext, [number] x, [optional string] padtext)

Description

lpad - Prepends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are prepended.

rpad - Appends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are appended.

@github-actions
Copy link

@jpedroantunes jpedroantunes force-pushed the feature/lpad-rpad-functions branch from d67c578 to a8837b1 Compare April 29, 2021 14:54
@jpedroantunes jpedroantunes force-pushed the feature/lpad-rpad-functions branch from 6087c44 to 4efc0fe Compare May 3, 2021 10:57
jvictorhuguenin pushed a commit to s1mbi0se/arrow that referenced this pull request Sep 21, 2021
…ing input values

#### Implement LPAD and RPAD functions for string input values.

- LPAD([string] basetext, [number] x, [optional string] padtext)
- RPAD([string] basetext, [number] x, [optional string] padtext)

#### Description

lpad - Prepends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are prepended.

rpad - Appends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are appended.

Closes apache#10173 from jpedroantunes/feature/lpad-rpad-functions and squashes the following commits:

4efc0fe <João Pedro> Add utf8_length method that ignore invalid char considering size 1
33a5a14 <João Pedro> Fix identation on function string registry
4c4b2f4 <João Pedro> Change lpad and rpad functions signature and definition
26b90b0 <João Pedro> Correct ci lint errors on gandiva
66594a0 <João Pedro> Correct lint local errors on gandiva
b6b63e9 <João Pedro> Add projector test for RPAD string function
dc72148 <João Pedro> Add function registry for RPAD string function without pad text
c270fb1 <João Pedro> Add base implementation and tests for RPAD functions
08d2053 <João Pedro> Add function registry for LPAD string function without pad text
585cad3 <João Pedro> Add base implementation and tests for LPAD function without pad texts considering string input values
73927fc <João Pedro> Add projector test for LPAD string function
2c929a9 <João Pedro> Add function registry for LPAD string function
aecaff6 <João Pedro> Add base implementation and tests for LPAD function considering string input values

Authored-by: João Pedro <joaop@simbioseventures.com>
Signed-off-by: Praveen <praveen@dremio.com>
(cherry picked from commit 0477cfc)
zhouyuan pushed a commit to zhouyuan/arrow that referenced this pull request Jun 13, 2022
…ing input values

- LPAD([string] basetext, [number] x, [optional string] padtext)
- RPAD([string] basetext, [number] x, [optional string] padtext)

lpad - Prepends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are prepended.

rpad - Appends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are appended.

Closes apache#10173 from jpedroantunes/feature/lpad-rpad-functions and squashes the following commits:

4efc0fe <João Pedro> Add utf8_length method that ignore invalid char considering size 1
33a5a14 <João Pedro> Fix identation on function string registry
4c4b2f4 <João Pedro> Change lpad and rpad functions signature and definition
26b90b0 <João Pedro> Correct ci lint errors on gandiva
66594a0 <João Pedro> Correct lint local errors on gandiva
b6b63e9 <João Pedro> Add projector test for RPAD string function
dc72148 <João Pedro> Add function registry for RPAD string function without pad text
c270fb1 <João Pedro> Add base implementation and tests for RPAD functions
08d2053 <João Pedro> Add function registry for LPAD string function without pad text
585cad3 <João Pedro> Add base implementation and tests for LPAD function without pad texts considering string input values
73927fc <João Pedro> Add projector test for LPAD string function
2c929a9 <João Pedro> Add function registry for LPAD string function
aecaff6 <João Pedro> Add base implementation and tests for LPAD function considering string input values

Authored-by: João Pedro <joaop@simbioseventures.com>
Signed-off-by: Praveen <praveen@dremio.com>
zhouyuan added a commit to oap-project/arrow that referenced this pull request Jun 14, 2022
* ARROW-12567: [C++][Gandiva] Implement LPAD and RPAD functions for string input values

- LPAD([string] basetext, [number] x, [optional string] padtext)
- RPAD([string] basetext, [number] x, [optional string] padtext)

lpad - Prepends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are prepended.

rpad - Appends padtext to basetext in a way that allows as many characters as possible from padtext given an output string length of x. When x is less than or equal to the length of basetext, only characters from basetext are printed in the output. If padtext is omitted then spaces are appended.

Closes apache#10173 from jpedroantunes/feature/lpad-rpad-functions and squashes the following commits:

4efc0fe <João Pedro> Add utf8_length method that ignore invalid char considering size 1
33a5a14 <João Pedro> Fix identation on function string registry
4c4b2f4 <João Pedro> Change lpad and rpad functions signature and definition
26b90b0 <João Pedro> Correct ci lint errors on gandiva
66594a0 <João Pedro> Correct lint local errors on gandiva
b6b63e9 <João Pedro> Add projector test for RPAD string function
dc72148 <João Pedro> Add function registry for RPAD string function without pad text
c270fb1 <João Pedro> Add base implementation and tests for RPAD functions
08d2053 <João Pedro> Add function registry for LPAD string function without pad text
585cad3 <João Pedro> Add base implementation and tests for LPAD function without pad texts considering string input values
73927fc <João Pedro> Add projector test for LPAD string function
2c929a9 <João Pedro> Add function registry for LPAD string function
aecaff6 <João Pedro> Add base implementation and tests for LPAD function considering string input values

Authored-by: João Pedro <joaop@simbioseventures.com>
Signed-off-by: Praveen <praveen@dremio.com>

* ARROW-13780: [Gandiva][UDF] Fix bug in udf space/rpad/lpad

- add max/min return length for space/lpad/rpad udfs
- correct return length

Closes apache#11016 from ZMZ91/bugfix/limit_return_chars_count

Authored-by: ZMZ <zmz@yanhuangdata.com>
Signed-off-by: Pindikura Ravindra <ravindra@dremio.com>
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>

* fix concat

Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>

Co-authored-by: João Pedro <joaop@simbioseventures.com>
Co-authored-by: ZMZ <zmz@yanhuangdata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants