rpad()

Creates a string of a given length by inserting padding characters to the right of the string. If the argument is null, this returns 0, and if it receives a value other than the string, it evaluates that value after converting it to a string.

Syntax

rpad(STR_EXPR, OUTPUT_LENGTH, [PADDING_EXPR])
Required Parameters
STR_EXPR
String expression
OUTPUT_LENGTH
Expression to specify the length of the result string after padding. If the STR_EXPR value is longer than OUTPUT_LENGTH, the function cuts the string according to OUTPUT_LENGTH and returns it.
Optional Parameters
PADDING_EXPR
Expression to specify the padding character (default: whitespace).

Usage

json "{}" 
| eval rpadded=rpad("string", 10)
  => "string     "

json "{}" 
| eval rpadded=rpad("string", 10, "p")
  => "stringpppp"

json "{}" 
| eval rpadded=rpad("string", 10, "pad")
  => "stringpadp"

json "{}" 
| eval rpadded=rpad("string", 3, "pad")
  => "str"

json "{}" 
| eval rpadded=rpad("string", null, "pad")
  => null

json "{}" 
| eval rpadded=rpad("string", 3, null)
  => null