lpad
lpad(str: string, length: int64, [pad: string]?) -> string
Left-pads a string to a target length counted in Unicode scalar values (runes), repeating an optional pad string that defaults to a single space.
If str, length, or the optional pad argument is null where constant evaluation applies, the result is null. A negative length produces an empty string. When length is not greater than the string’s current length, the value is truncated on the right to exactly length characters (still measured in runes). Padding repeats the pad string as needed and may use only a prefix of the final pad repetition to reach the exact length.
For padding on the other side, use rpad.
Domain
This is a scalar function (calculates a single output value for a single input row).
Categories
Examples
make_col id_padded:lpad(string(id), 8)
Pads numeric identifiers converted to string on the left with spaces until the column is eight characters wide.
make_col sku:lpad(product_code, 12, "0")
Uses a leading zero pad string so short product codes line up to a fixed width for joins or display.
Updated 19 days ago