table (DataFrameReader)
Returns the specified table as a DataFrame.
Syntax
table(tableName)
Parameters
Parameter | Type | Description |
|---|---|---|
| str | The name of the table. |
Returns
DataFrame
Examples
Python
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")