---
title: table (SparkSession)
description: "SparkSession.table method in PySpark: Returns the specified table as a DataFrame."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/sparksession/table
---

# table (SparkSession)

Returns the specified table as a `DataFrame`.

## Syntax

```
table(tableName)
```

## Parameters

| Parameter   | Type | Description                 |
| ----------- | ---- | --------------------------- |
| `tableName` | str  | The table name to retrieve. |

## Returns

`DataFrame`

## Notes

In Spark Classic, a temporary view referenced in `spark.table` is resolved immediately. In Spark Connect, it is lazily analyzed, so if a view is dropped, modified, or replaced after `spark.table`, the execution may fail or generate different results.

## Examples

```python
spark.range(5).createOrReplaceTempView("table1")
spark.table("table1").sort("id").show()
# +---+
# | id|
# +---+
# |  0|
# |  1|
# |  2|
# |  3|
# |  4|
# +---+
```
