DESCRIBE TABLE
Devolve a informação básica de metadados de uma tabela. As informações de metadados incluem nome de coluna, tipo de coluna e comentário de coluna. Opcionalmente, pode especificar uma especificação de partição ou nome de coluna para devolver os metadados relativos a uma divisória ou coluna, respectivamente.
Sintaxe
{ DESC | DESCRIBE } TABLE [EXTENDED] [ format ] table_identifier [ partition_spec ] [ col_name ]
EXTENDED
Apresentar informações detalhadas sobre as colunas especificadas, incluindo as estatísticas da coluna recolhidas pelo comando ANALYZE TABLE table_name COMPUTE STATISTICS FOR COLUMNS column_name [column_name, ...]
.
Parâmetros
formato
O formato opcional de descrever a saída. Se
EXTENDED
for especificado, então são devolvidas informações adicionais de metadados (como base de dados dos pais, proprietário e tempo de acesso).table_identifier
[database_name.] table_name
: Nome de mesa, opcionalmente qualificado com nome de base de dados.delta.
<>de caminho a
partition_spec
Um parâmetro opcional que especifica uma lista separada por vírgula de pares de valores-chave para divisórias. Quando especificado, os metadados de partição adicionais são devolvidos.
Sintaxe:
PARTITION ( partition_col_name = partition_col_val [ , ... ] )
col_name
Um parâmetro opcional que o nome da coluna precisa de ser descrito. O nome da coluna fornecida pode ser qualificado opcionalmente. Parâmetros
partition_spec
ecol_name
são mutuamente exclusivos e não podem ser especificados em conjunto. Atualmente, não é permitido especificar colunas aninhadas.Sintaxe:
[database_name.] [ table_name. ] column_name
Exemplos
-- 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.
```sql
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|
+---------+----------+
DEScreva detalhes (Delta Lake on Azure Databricks)
DESCRIBE DETAIL [db_name.]table_name
DESCRIBE DETAIL delta.`<path-to-table>`
Devolva informações sobre esquema, divisórias, tamanho da mesa, e assim por diante. Por exemplo, pode ver as versões atuais do leitor e do escritor de uma tabela.