pyspark.sql.SparkSession.table

SparkSession.table(tableName)[source]

Returns the specified table as a DataFrame.

New in version 2.0.0.

Returns
DataFrame

Examples

>>> df.createOrReplaceTempView("table1")
>>> df2 = spark.table("table1")
>>> sorted(df.collect()) == sorted(df2.collect())
True