pyspark.sql.DataFrameReader.table#

DataFrameReader.table(tableName)[source]#

Returns the specified table as a DataFrame.

New in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
tableNamestr

string, name of the table.

Examples

>>> df = spark.range(10)
>>> df.createOrReplaceTempView('tblA')
>>> spark.read.table('tblA').show()
+---+
| id|
+---+
|  0|
|  1|
|  2|
|  3|
|  4|
|  5|
|  6|
|  7|
|  8|
|  9|
+---+
>>> _ = spark.sql("DROP TABLE tblA")