pyspark.sql.functions.typeof

pyspark.sql.functions.typeof(col: ColumnOrName) → pyspark.sql.column.Column[source]

Return DDL-formatted type string for the data type of the input.

New in version 3.5.0.

Parameters
colColumn or str

Examples

>>> df = spark.createDataFrame([(1,)], ["a"])
>>> df.select(typeof(df.a).alias('r')).collect()
[Row(r='bigint')]