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: The string expression to left-pad.
    Expression<String>
  • Length: The width to pad the string to.
    Expression<Integer>
  • Pad: The string used to pad.
    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 (ANSI mode on)

Argument values:

  • Expression: String
  • Length: Length
  • Pad: Pad
StringLengthPadOutput
null15*null
Hello world!null*null
Hello, world!15nullnull
nullnullnullnull

Example 3: Null case (ANSI mode off)

Argument values:

  • Expression: String
  • Length: Length
  • Pad: Pad
StringLengthPadOutput
null15*null
Hello world!null*empty string
Hello, world!15nullHello, world!
nullnullnullnull

Example 4: Edge case

Description: Length less than the string, it will truncate the string.

Argument values:

  • Expression: Hello world!
  • Length: 5
  • Pad: *

Output: Hello


Example 5: Edge case

Description: Length of 0 will remove the string.

Argument values:

  • Expression: Hello world!
  • Length: 0
  • Pad: *

Output: empty string