Right pad string

Supported in: Batch, 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<String>
  • Length - no description
    Expression<Integer>
  • Pad - no description
    Expression<String>

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
StringLengthPadOutput
null15*null
Hello world!null*empty string
Hello, world!15nullHello, world!
nullnullnullnull

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