Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Get the table or view with the specified name. This table can be a temporary view or a table/view. This throws an AnalysisException when no Table can be found.
Syntax
getTable(tableName: str)
Parameters
| Parameter | Type | Description |
|---|---|---|
tableName |
str | Name of the table to get. Can be qualified with catalog name. |
Returns
Table
The table found by the name.
Examples
_ = spark.sql("DROP TABLE IF EXISTS tbl1")
_ = spark.sql("CREATE TABLE tbl1 (name STRING, age INT) USING parquet")
spark.catalog.getTable("tbl1")
# Table(name='tbl1', catalog='spark_catalog', namespace=['default'], ...
# Using the fully qualified name with the catalog name.
spark.catalog.getTable("default.tbl1")
# Table(name='tbl1', catalog='spark_catalog', namespace=['default'], ...
spark.catalog.getTable("spark_catalog.default.tbl1")
# Table(name='tbl1', catalog='spark_catalog', namespace=['default'], ...
_ = spark.sql("DROP TABLE tbl1")
# Throw an analysis exception when the table does not exist.
spark.catalog.getTable("tbl1")
# Traceback (most recent call last):
# ...
# AnalysisException: ...