Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
rpad
functionApplies to: Databricks SQL
Databricks Runtime
Returns expr
, right-padded with pad
to a length of len
.
rpad(expr, len [, pad] )
expr
: A STRING
or BINARY
expression to be padded.len
: An INTEGER
expression.pad
: An optional STRING
or BINARY
expression with the pattern for padding. The default is a space character for STRING
and x'00' for BINARY
.A BINARY
if both expr
and pad
are BINARY
. Otherwise, returns a STRING
.
If expr
is longer than len
, the return value is shortened to len
characters.
If you do not specify pad
, a STRING
expr
is padded to the right with space characters, whereas a BINARY
expr
is padded to the right with x'00' bytes.
If len
is less than 1, an empty string.
BINARY
is supported since: Databricks Runtime 11.0.
> SELECT rpad('hi', 5, 'ab');
hiaba
> SELECT rpad('hi', 1, '??');
h
> SELECT rpad('hi', 5);
hi
> SELECT hex(rpad(x'1020', 5, x'05'))
1020050505
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in