pyspark.sql.functions.quote#

pyspark.sql.functions.quote(col)[source]#

Returns str enclosed by single quotes and each instance of single quote in it is preceded by a backslash.

New in version 4.1.0.

Parameters
colColumn or column name

target column to be quoted.

Returns
Column

quoted string

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame(["Don't"], "STRING")
>>> df.select("*", sf.quote("value")).show()
+-----+------------+
|value|quote(value)|
+-----+------------+
|Don't|    'Don\'t'|
+-----+------------+