MOSTRAR PARTIÇÕES

Aplica-se a:verificar a verificação sim do SQL do Databricks marcada como sim Databricks Runtime

Lista as partições de uma tabela.

Sintaxe

SHOW PARTITIONS table_name [ PARTITION clause ]

Parâmetros

  • table_name

    Identifica a tabela. O nome não pode incluir uma especificação temporal.

  • Cláusula PARTITION

    Um parâmetro opcional que especifica uma partição. Se a especificação for apenas parcial, são devolvidas todas as partições correspondentes. Se não for especificada nenhuma partição, o SQL do Databricks devolve todas as partições.

Exemplos

-- create a partitioned table and insert a few rows.
> USE salesdb;
> CREATE TABLE customer(id INT, name STRING) PARTITIONED BY (state STRING, city STRING);
> INSERT INTO customer PARTITION (state = 'CA', city = 'Fremont') VALUES (100, 'John');
> INSERT INTO customer PARTITION (state = 'CA', city = 'San Jose') VALUES (200, 'Marry');
> INSERT INTO customer PARTITION (state = 'AZ', city = 'Peoria') VALUES (300, 'Daniel');

-- Lists all partitions for table `customer`
> SHOW PARTITIONS customer;
   state=AZ/city=Peoria
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Lists all partitions for the qualified table `customer`
> SHOW PARTITIONS salesdb.customer;
   state=AZ/city=Peoria
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Specify a full partition spec to list specific partition
> SHOW PARTITIONS customer PARTITION (state = 'CA', city = 'Fremont');
 |state=CA/city=Fremont|

-- Specify a partial partition spec to list the specific partitions
> SHOW PARTITIONS customer PARTITION (state = 'CA');
  state=CA/city=Fremont
 state=CA/city=San Jose

-- Specify a partial spec to list specific partition
> SHOW PARTITIONS customer PARTITION (city =  'San Jose');
 state=CA/city=San Jose