Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
Platí pro:
Databricks SQL
Databricks Runtime
Vrátí základní informace o metadatech tabulky. Informace o metadatech zahrnují název sloupce, typ sloupce a komentář sloupce. Volitelně můžete zadat specifikace oddílu nebo název sloupce, který vrátí metadata týkající se oddílu nebo sloupce. U tabulek Delta se nevrátí všechna pole.
Metadata se vrátí buď ve formuláři sestavy, nebo jako dokument JSON.
Důležitý
Pomocí DESCRIBE AS JSON můžete analyzovat výstup programově. Formát sestavy, který není JSON, může podléhat změnám.
Syntaxe
{ DESC | DESCRIBE } [ TABLE ] [ EXTENDED ] table_name { [ PARTITION clause ] | [ column_name ] } [ AS JSON ]
Pro kompatibilitu lze FORMATTED zadat jako synonymum pro EXTENDED.
Parametry
EXTENDEDPokud je zadané zobrazení podrobných informací o zadaných sloupcích, včetně statistik sloupců shromážděných příkazem, a dalších informací o metadatech (například kvalifikátor schématu, vlastníka a doby přístupu).
-
Identifikuje tabulku, která se má popsat. Název nesmí používat dočasnou specifikaci nebo specifikaci možností. Pokud tabulku nenajdete, Azure Databricks vyvolá TABLE_OR_VIEW_NOT_FOUND chybu.
-
Volitelný parametr, který směruje Databricks SQL, aby vrátil metadata přidání pro pojmenované oddíly.
-
Volitelný parametr s názvem sloupce, který je potřeba popsat. Momentálně nelze specifikovat vnořené sloupce.
Formát JSON je podporovaný pro jednotlivé sloupce.
AS JSONPlatí pro:
Databricks SQL
Databricks Runtime 16.2 a vyššíVolitelně vrátí metadata tabulky jako řetězec JSON místo sestavy čitelné pro člověka. Tento formát použijte při analýze výsledku pomocí programu.
Podporováno pouze ve formátu
EXTENDED.
Parametry partition_spec a column_name se vzájemně vylučují a nelze je zadat společně.
Výstup ve formátu JSON
Při zadání AS JSON se výstup vrátí jako řetězec JSON. Podporuje se následující schéma:
{
"table_name": "<table_name>",
"catalog_name": "<catalog_name>",
"schema_name": "<schema_name>",
"namespace": ["<schema_name>"],
"type": "<table_type>",
"provider": "<provider>",
"columns": [
{
"name": "<name>",
"type": <type_json>,
"comment": "<comment>",
"nullable": <boolean>,
"default": "<default_val>",
"is_measure": <boolean>, // Included only for measure columns of metric views
}
],
"partition_values": {
"<col_name>": "<val>"
},
"partition_columns": ["col1", "col2"],
"location": "<path>",
"view_text": "<view_text>",
"view_original_text": "<view_original_text>",
"view_schema_mode": "<view_schema_mode>",
"view_catalog_and_namespace": "<view_catalog_and_namespace>",
"view_query_output_columns": ["<col_name>"],
"comment": "<comment>",
"table_properties": {
"property1": "<property1>",
"property2": "<property2>"
},
"statistics": {
"num_rows": <count>,
"size_in_bytes": <bytes>,
"table_change_stats": {
"inserted": <count>,
"deleted": <count>,
"updated": <count>,
"change_percent": <percent_changed_float>
}
},
"storage_properties": {
"property1": "<property1>",
"property2": "<property2>"
},
"serde_library": "<serde_library>",
"input_format": "<input_format>",
"output_format": "<output_format>",
"num_buckets": <num_buckets>,
"bucket_columns": ["<col_name>"],
"sort_columns": ["<col_name>"],
"created_time": "<timestamp_ISO-8601>",
"created_by": "<created_by>",
"last_access": "<timestamp_ISO-8601>",
"partition_provider": "<partition_provider>",
"collation": "<default_collation>", // Available in :re[DBR] 16.4 and above
"language": "<language>", // Language such as YAML, included only for metric views
"row_filter": { // Available in :re[DBR] 17.0 and above
"filter_function": {
"catalog_name": "<catalog_name>",
"schema_name": "<schema_name>",
"function_name: "<function_name>",
"specific_name": "<specific_name>"
},
"arguments": ["<arg1>", "<arg2>"]
},
"column_masks": [ // Available in :re[DBR] 17.0 and above
{"column_name": "<column_name>",
"mask_function": {
"catalog_name": "<catalog_name>",
"schema_name": "<schema_name>",
"function_name: "<function_name>",
"specific_name": "<specific_name>"
},
"arguments": ["<arg1>", "<arg2>"]
}
]
"refresh_information": { // Available in :re[DBR] 17.3 and above, included only for materialized views and streaming tables
"last_refreshed_at": "<timestamp_ISO-8601>",
"last_refresh_type": "<refresh_type>",
"latest_refresh_status": "<refresh_status>",
"latest_refresh_link": "<refresh_url>",
"refresh_schedule": "<schedule>"
}
}
Níže jsou uvedené definice schématu pro <type_json>:
| Typ SQL | Reprezentace JSON |
|---|---|
| TINYINT | { "name" : "tinyint" } |
| SMALLINT | { "name" : "smallint" } |
| INT | { "name" : "int" } |
| BIGINT | { "name" : "bigint" } |
| PLOUT | { "name" : "float" } |
| DVOJITÝ | { "name" : "double" } |
| DESETINNÉ ČÍSLO(p, s) | { "name" : "decimal", "precision": p, "scale": s } |
| ŘETĚZEC | { "name" : "string", "collation": "<collation>" } |
| VARCHAR(n) | { "name" : "varchar", "length": n } |
| ZNAK(n) | { "name" : "char", "length": n } |
| BINÁRNÍ | { "name" : "binary" } |
| Boolean | { "name" : "boolean" } |
| RANDE | { "name" : "date" } |
| ČASOVÁ ZNAČKA | { "name" : "timestamp_ltz" } |
| TIMESTAMP_NTZ | { "name" : "timestamp_ntz" } |
| INTERVAL start_unit DO end_unit | { "name" : "interval", "start_unit": "<start_unit>", "end_unit": "<end_unit>" } |
| POLE<element_type> | { "name" : "array", "element_type": <type_json>, "element_nullable": <boolean_val> } |
| MAP<typ_klíče, typ_hodnoty> | { "name" : "map", "key_type": <type_json>, "value_type": <type_json>, "element_nullable": <boolean_val> } |
| STRUCT<field_name ..., ...> | { "name" : "struct", "fields": [ {"name" : "<field_name>", "type" : <type_json>, “nullable”: <boolean_val>, "comment": “<field_comment>”, "default": “<default_val>”}] } |
| VARIANTA | { "name" : "variant" } |
Příklady
-- Creates a table `customer`. Assumes current schema 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 schema, 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.
> DESCRIBE EXTENDED customer AS JSON;
{
"table_name":"customer",
"catalog_name":"spark_catalog",
"schema_name":"default",
"namespace":["default"],
"columns":[
{"name":"cust_id","type":{"name":"integer"},"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"]}
-- The JSON describe of a metric view
> DESCRIBE EXTENDED region_sales_metrics AS JSON;
{
"table_name":"region_sales_metrics",
"catalog_name":"main",
"namespace":["default"],
"schema_name":"default",
"columns":[
{"name":"month","type":{"name":"timestamp_ltz"},"nullable":true},
{"name":"status","type":{"name":"string","collation":"UTF8_BINARY"},"nullable":true},
{"name":"prder_priority","type":{"name":"string","collation":"UTF8_BINARY"},"nullable":true},
{"name":"count_orders","type":{"name":"bigint"},"nullable":false,"is_measure":true},
{"name":"total_revenue","type":{"name":"decimal","precision":28,"scale":2},"nullable":true,"is_measure":true},
{"name":"total_revenue_per_customer","type":{"name":"decimal","precision":38,"scale":12},"nullable":true,"is_measure":true}],
"owner":"alf@melmak.et",
"created_time":"2025-05-18T23:45:25Z",
"last_access":"UNKNOWN",
"created_by":"Spark ",
"type":"METRIC_VIEW",
"comment":"A metric view for regional sales metrics.",
"view_text":"\n version: 0.1\n source: samples.tpch.orders\n filter: o_orderdate > '1990-01-01'\n dimensions:\n - name: month\n expr: date_trunc('MONTH', o_orderdate)\n - name: status\n expr: case\n when o_orderstatus = 'O' then 'Open'\n when o_orderstatus = 'P' then 'Processing'\n when o_orderstatus = 'F' then 'Fulfilled'\n end\n - name: prder_priority\n expr: split(o_orderpriority, '-')[1]\n measures:\n - name: count_orders\n expr: count(1)\n - name: total_revenue\n expr: SUM(o_totalprice)\n - name: total_revenue_per_customer\n expr: SUM(o_totalprice) / count(distinct o_custkey)\n ","language":"YAML","table_properties":{"metric_view.from.name":"samples.tpch.orders","metric_view.from.type":"ASSET","metric_view.where":"o_orderdate > '1990-01-01'"},
"view_creation_spark_configuration":{ ... },
"collation":"UTF8_BINARY"}
POPIŠTE PODROBNOSTI
DESCRIBE DETAIL [schema_name.]table_name
Vrátí informace o schématu, dělení, velikosti tabulky atd. Například u tabulek Delta můžete zobrazit aktuální verze tabulky pro čtení a zápis . Viz Tabulka pro kontrolu podrobností pomocí "describe detail" pro detaily schématu.