pyspark.sql.functions.reflect#

pyspark.sql.functions.reflect(*cols)[source]#

Calls a method with reflection.

New in version 3.5.0.

Parameters
colsColumn or column name

the first element should be a Column representing literal string for the class name, and the second element should be a Column representing literal string for the method name, and the remaining are input arguments (Columns or column names) to the Java method.

Examples

>>> import pyspark.sql.functions as sf
>>> df = spark.createDataFrame([('a5cf6c42-0c85-418f-af6c-3e4e5b1328f2',)], ['a'])
>>> df.select(
...     sf.reflect(sf.lit('java.util.UUID'), sf.lit('fromString'), 'a')
... ).show(truncate=False)
+--------------------------------------+
|reflect(java.util.UUID, fromString, a)|
+--------------------------------------+
|a5cf6c42-0c85-418f-af6c-3e4e5b1328f2  |
+--------------------------------------+