pyspark.sql.Catalog.getCreateTableString#

Catalog.getCreateTableString(tableName, asSerde=False)[source]#

Returns the SHOW CREATE TABLE DDL string for a relation.

New in version 4.2.0.

Parameters
tableNamestr

Table or view name. May be qualified with catalog and database (namespace).

asSerdebool, optional

If True, request Hive serde DDL when applicable.

Returns
str

DDL string from SHOW CREATE TABLE.

Examples

>>> _ = spark.sql("DROP TABLE IF EXISTS tbl_ddl_doc")
>>> _ = spark.sql("CREATE TABLE tbl_ddl_doc (id INT) USING parquet")
>>> "CREATE" in spark.catalog.getCreateTableString("tbl_ddl_doc").upper()
True
>>> _ = spark.sql("DROP TABLE tbl_ddl_doc")