Catalog.
getTable
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.
AnalysisException
New in version 3.4.0.
name of the table to get.
Changed in version 3.4.0: Allow tableName to be qualified with catalog name.
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: ...