Left pad string(左填充字符串(Left pad string))¶
Supported in: Batch, Faster, Streaming
Left-pad the string column to width of length with pad.
Expression categories: String
Declared arguments¶
- Expression: no description
Expression\ - Length: no description
Expression\ - Pad: no description
Expression\
Output type: String
Examples¶
Example 1: Base case¶
Argument values:
- Expression: Hello world!
- Length: 15
- Pad: *
Output: ***Hello world!
Example 2: Null case¶
Argument values:
- Expression:
String - Length:
Length - Pad:
Pad
| String | Length | Pad | Output |
|---|---|---|---|
| null | 15 | * | null |
| Hello world! | null | * | empty string |
| Hello, world! | 15 | null | Hello, world! |
| null | null | null | null |
Example 3: Edge case¶
Description: Length less than the string, it will truncate the string.
Argument values:
- Expression: Hello world!
- Length: 5
- Pad: *
Output: Hello
Example 4: Edge case¶
Description: Length of 0 will remove the string.
Argument values:
- Expression: Hello world!
- Length: 0
- Pad: *
Output: empty string
中文翻译¶
左填充字符串(Left pad string)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
使用填充字符(pad)将字符串列(string column)左填充至指定长度(length)。
表达式类别: 字符串(String)
声明的参数¶
- 表达式(Expression): 无描述
表达式\ - 长度(Length): 无描述
表达式\ - 填充字符(Pad): 无描述
表达式\
输出类型: String
示例¶
示例 1:基本情况¶
参数值:
- 表达式: Hello world!
- 长度: 15
- 填充字符: *
输出: ***Hello world!
示例 2:空值情况¶
参数值:
- 表达式:
String - 长度:
Length - 填充字符:
Pad
| String | Length | Pad | 输出 |
|---|---|---|---|
| null | 15 | * | null |
| Hello world! | null | * | 空字符串 |
| Hello, world! | 15 | null | Hello, world! |
| null | null | null | null |
示例 3:边界情况¶
描述: 当长度小于字符串时,将截断字符串。
参数值:
- 表达式: Hello world!
- 长度: 5
- 填充字符: *
输出: Hello
示例 4:边界情况¶
描述: 长度为 0 时将移除字符串。
参数值:
- 表达式: Hello world!
- 长度: 0
- 填充字符: *
输出: 空字符串