DESCRIBE TABLE

Description

DESCRIBE TABLE statement returns the basic metadata information of a table. The metadata information includes column name, column type and column comment. Optionally a partition spec or column name may be specified to return the metadata pertaining to a partition or column respectively.

Syntax

{ DESC | DESCRIBE } [ TABLE ] [ format ] table_identifier [ partition_spec ] [ col_name ] [ AS JSON ]

Parameters

Spark SQL Data Types JSON Representation
ByteType { "name" : "tinyint" }
ShortType { "name" : "smallint" }
IntegerType { "name" : "int" }
LongType { "name" : "bigint" }
FloatType { "name" : "float" }
DoubleType { "name" : "double" }
DecimalType { "name" : "decimal", "precision": p, "scale": s }
StringType { "name" : "string", "collation": "<collation>" }
VarCharType { "name" : "varchar", "length": n }
CharType { "name" : "char", "length": n }
BinaryType { "name" : "binary" }
BooleanType { "name" : "boolean" }
DateType { "name" : "date" }
VariantType { "name" : "variant" }
TimestampType { "name" : "timestamp_ltz" }
TimestampNTZType { "name" : "timestamp_ntz" }
YearMonthIntervalType { "name" : "interval", "start_unit": "<start_unit>", "end_unit": "<end_unit>" }
DayTimeIntervalType { "name" : "interval", "start_unit": "<start_unit>", "end_unit": "<end_unit>" }
ArrayType { "name" : "array", "element_type": <type_json>, "element_nullable": <boolean> }
MapType { "name" : "map", "key_type": <type_json>, "value_type": <type_json>, "value_nullable": <boolean> }
StructType { "name" : "struct", "fields": [ {"name" : "field1", "type" : <type_json>, “nullable”: <boolean>, "comment": “<comment>”, "default": “<default_val>”}, ... ] }

Examples

-- Creates a table `customer`. Assumes current database is `salesdb`.
CREATE TABLE customer(
        cust_id INT,
        state VARCHAR(20),
        name STRING COMMENT 'Short name'
    )
    USING parquet
    PARTITIONED BY (state);
    
INSERT INTO customer PARTITION (state = 'AR') VALUES (100, 'Mike');
    
-- Returns basic metadata information for unqualified table `customer`
DESCRIBE TABLE customer;
+-----------------------+---------+----------+
|               col_name|data_type|   comment|
+-----------------------+---------+----------+
|                cust_id|      int|      null|
|                   name|   string|Short name|
|                  state|   string|      null|
|# Partition Information|         |          |
|             # col_name|data_type|   comment|
|                  state|   string|      null|
+-----------------------+---------+----------+

-- Returns basic metadata information for qualified table `customer`
DESCRIBE TABLE salesdb.customer;
+-----------------------+---------+----------+
|               col_name|data_type|   comment|
+-----------------------+---------+----------+
|                cust_id|      int|      null|
|                   name|   string|Short name|
|                  state|   string|      null|
|# Partition Information|         |          |
|             # col_name|data_type|   comment|
|                  state|   string|      null|
+-----------------------+---------+----------+

-- Returns additional metadata such as parent database, owner, access time etc.
DESCRIBE TABLE EXTENDED customer;
+----------------------------+------------------------------+----------+
|                    col_name|                     data_type|   comment|
+----------------------------+------------------------------+----------+
|                     cust_id|                           int|      null|
|                        name|                        string|Short name|
|                       state|                        string|      null|
|     # Partition Information|                              |          |
|                  # col_name|                     data_type|   comment|
|                       state|                        string|      null|
|                            |                              |          |
|# Detailed Table Information|                              |          |
|                    Database|                       default|          |
|                       Table|                      customer|          |
|                       Owner|                 <TABLE OWNER>|          |
|                Created Time|  Tue Apr 07 22:56:34 JST 2020|          |
|                 Last Access|                       UNKNOWN|          |
|                  Created By|               <SPARK VERSION>|          |
|                        Type|                       MANAGED|          |
|                    Provider|                       parquet|          |
|                    Location|file:/tmp/salesdb.db/custom...|          |
|               Serde Library|org.apache.hadoop.hive.ql.i...|          |
|                 InputFormat|org.apache.hadoop.hive.ql.i...|          |
|                OutputFormat|org.apache.hadoop.hive.ql.i...|          |
|          Partition Provider|                       Catalog|          |
+----------------------------+------------------------------+----------+

-- Returns partition metadata such as partitioning column name, column type and comment.
DESCRIBE TABLE EXTENDED customer PARTITION (state = 'AR');
+------------------------------+------------------------------+----------+
|                      col_name|                     data_type|   comment|
+------------------------------+------------------------------+----------+
|                       cust_id|                           int|      null|
|                          name|                        string|Short name|
|                         state|                        string|      null|
|       # Partition Information|                              |          |
|                    # col_name|                     data_type|   comment|
|                         state|                        string|      null|
|                              |                              |          |
|# Detailed Partition Inform...|                              |          |
|                      Database|                       default|          |
|                         Table|                      customer|          |
|              Partition Values|                    [state=AR]|          |
|                      Location|file:/tmp/salesdb.db/custom...|          |
|                 Serde Library|org.apache.hadoop.hive.ql.i...|          |
|                   InputFormat|org.apache.hadoop.hive.ql.i...|          |
|                  OutputFormat|org.apache.hadoop.hive.ql.i...|          |
|            Storage Properties|[serialization.format=1, pa...|          |
|          Partition Parameters|{transient_lastDdlTime=1586...|          |
|                  Created Time|  Tue Apr 07 23:05:43 JST 2020|          |
|                   Last Access|                       UNKNOWN|          |
|          Partition Statistics|                     659 bytes|          |
|                              |                              |          |
|         # Storage Information|                              |          |
|                      Location|file:/tmp/salesdb.db/custom...|          |
|                 Serde Library|org.apache.hadoop.hive.ql.i...|          |
|                   InputFormat|org.apache.hadoop.hive.ql.i...|          |
|                  OutputFormat|org.apache.hadoop.hive.ql.i...|          |
+------------------------------+------------------------------+----------+

-- Returns the metadata for `name` column.
-- Optional `TABLE` clause is omitted and column is fully qualified.
DESCRIBE customer salesdb.customer.name;
+---------+----------+
|info_name|info_value|
+---------+----------+
| col_name|      name|
|data_type|    string|
|  comment|Short name|
+---------+----------+

-- Returns the table metadata in JSON format.
-- (Formatted for readability; the actual output is on a single line.)
DESC FORMATTED customer AS JSON;
{
  "table_name": "customer",
  "catalog_name": "spark_catalog",
  "schema_name": "default",
  "namespace": ["default"],
  "columns": [
    {"name": "cust_id", "type": {"name": "int"}, "nullable": true},
    {"name": "name", "type": {"name": "string"}, "comment": "Short name", "nullable": true},
    {"name": "state", "type": {"name": "varchar", "length": 20}, "nullable": true}
  ],
  "location": "file:/tmp/salesdb.db/custom...",
  "created_time": "2020-04-07T14:05:43Z",
  "last_access": "UNKNOWN",
  "created_by": "None",
  "type": "MANAGED",
  "provider": "parquet",
  "partition_provider": "Catalog",
  "partition_columns": ["state"]
}

-- DESCRIBE EXTENDED on a view emits view-specific rows.
SET PATH = spark_catalog.default, system.builtin;
CREATE VIEW recent_customers AS
    SELECT cust_id, name FROM customer WHERE cust_id > 1000;

DESCRIBE EXTENDED recent_customers;
+----------------------------+---------------------------------------+--------+
|                    col_name|                              data_type| comment|
+----------------------------+---------------------------------------+--------+
|                     cust_id|                                    int|    null|
|                        name|                                 string|    null|
|                            |                                       |        |
|# Detailed Table Information|                                       |        |
|                    Catalog |                          spark_catalog|        |
|                    Database|                                default|        |
|                       Table|                       recent_customers|        |
|                        Type|                                   VIEW|        |
|                   View Text|SELECT cust_id, name FROM customer ... |        |
|          View Original Text|SELECT cust_id, name FROM customer ... |        |
|            View Schema Mode|                           COMPENSATION|        |
| View Catalog and Namespace|                spark_catalog.default   |        |
|   View Query Output Columns|                   [`cust_id`, `name`]  |        |
|                    SQL Path|   spark_catalog.default, system.builtin|        |
+----------------------------+---------------------------------------+--------+

-- The same metadata in JSON form.
-- (Formatted for readability; the actual output is on a single line.)
DESCRIBE EXTENDED recent_customers AS JSON;
{
  "table_name": "recent_customers",
  "catalog_name": "spark_catalog",
  "schema_name": "default",
  "namespace": ["default"],
  "columns": [
    {"name": "cust_id", "type": {"name": "int"}, "nullable": true},
    {"name": "name", "type": {"name": "string", "collation": "UTF8_BINARY"}, "nullable": true}
  ],
  "created_time": "2026-05-22T10:00:00Z",
  "last_access": "UNKNOWN",
  "created_by": "Spark 4.2.0",
  "type": "VIEW",
  "collation": "UTF8_BINARY",
  "view_text": "SELECT cust_id, name FROM customer WHERE cust_id > 1000",
  "view_original_text": "SELECT cust_id, name FROM customer WHERE cust_id > 1000",
  "view_schema_mode": "COMPENSATION",
  "view_catalog_and_namespace": "spark_catalog.default",
  "view_query_output_columns": ["cust_id", "name"],
  "sql_path": [
    {"catalog_name": "spark_catalog", "namespace": ["default"]},
    {"catalog_name": "system", "namespace": ["builtin"]}
  ],
  "view_creation_spark_configuration": {
    "spark.sql.ansi.enabled": "true"
  }
}