Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add center function #282

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions extensions/functions_string.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,44 @@ scalar_functions:
name: "characters"
description: "The string of characters to use for padding."
return: "string"
-
name: center
description: >-
Center the input string by padding the sides with a single `character` until the specified
`length` of the string has been reached. By default, if the `length` will be reached with
an uneven number of padding, the extra padding will be applied to the right side.
The side with extra padding can be controlled with the `padding` option.

Behavior is undefined if the number of characters passed to the `character` argument is not 1.
impls:
- args:
- name: padding
options: [ RIGHT, LEFT ]
required: false
- value: "varchar<L1>"
name: "input"
description: "The string to pad."
- value: i32
name: "length"
description: "The length of the output string."
- value: "varchar<1>"
name: "character"
description: "The character to use for padding."
return: "varchar<L1>"
- args:
- name: padding
options: [ RIGHT, LEFT ]
required: false
- value: "string"
name: "input"
description: "The string to pad."
- value: i32
name: "length"
description: "The length of the output string."
- value: "string"
name: "character"
description: "The character to use for padding."
return: "string"
-
name: left
description: Extract count characters starting from the left of the string.
Expand Down