pyspark.sql.functions.right#

pyspark.sql.functions.right(str, len)[source]#

Returns the rightmost len`(`len can be string type) characters from the string str, if len is less or equal than 0 the result is an empty string.

Added in version 3.5.0.

Parameters:
strColumn or str

Input column or strings. A column that evaluates to a string.

lenColumn or str

Input column or strings, the rightmost len. A column that evaluates to an integer.

Examples

>>> df = spark.createDataFrame([("Spark SQL", 3,)], ['a', 'b'])
>>> df.select(right(df.a, df.b).alias('r')).collect()
[Row(r='SQL')]