rpad
Right-pad the string column to width len with pad.
For the corresponding Databricks SQL function, see rpad function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.rpad(col=<col>, len=<len>, pad=<pad>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| target column to work on. |
|
| length of the final string. |
|
| chars to prepend. |
Returns
pyspark.sql.Column: right padded result.
Examples
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('abcd',), ('xyz',), ('12',)], ['s',])
df.select("*", dbf.rpad(df.s, 6, '#')).show()
df = spark.createDataFrame([('abcd',), ('xyz',), ('12',)], ['s',])
df.select("*", dbf.rpad(df.s, 6, dbf.lit(b"\x75\x76"))).show()