跳转至

Right pad string(右填充字符串(Right pad string))

Supported in: Batch, Faster, Streaming

Right-pad the string column to width of length with pad. If the length of the string is greater than the length provided, it will be trimmed.

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 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



中文翻译


右填充字符串(Right 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) 输出(Output)
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
  • 填充字符: *

输出: 空字符串