DESCRIBE QUERY

Description

The DESCRIBE QUERY statement is used to return the metadata of output of a query. A shorthand DESC may be used instead of DESCRIBE to describe the query output.

Syntax

  1. { DESC | DESCRIBE } [ QUERY ] input_statement

Parameters

  • QUERY This clause is optional and may be omitted.

  • input_statement

    Specifies a result set producing statement and may be one of the following:

    • a SELECT statement
    • a CTE(Common table expression) statement
    • an INLINE TABLE statement
    • a TABLE statement
    • a FROM statement`

    Please refer to select-statement for a detailed syntax of the query parameter.

Examples

  1. -- Create table `person`
  2. CREATE TABLE person (name STRING , age INT COMMENT 'Age column', address STRING);
  3. -- Returns column metadata information for a simple select query
  4. DESCRIBE QUERY SELECT age, sum(age) FROM person GROUP BY age;
  5. +--------+---------+----------+
  6. |col_name|data_type| comment|
  7. +--------+---------+----------+
  8. | age| int|Age column|
  9. |sum(age)| bigint| null|
  10. +--------+---------+----------+
  11. -- Returns column metadata information for common table expression (`CTE`).
  12. DESCRIBE QUERY WITH all_names_cte
  13. AS (SELECT name from person) SELECT * FROM all_names_cte;
  14. +--------+---------+-------+
  15. |col_name|data_type|comment|
  16. +--------+---------+-------+
  17. | name| string| null|
  18. +--------+---------+-------+
  19. -- Returns column metadata information for an inline table.
  20. DESC QUERY VALUES(100, 'John', 10000.20D) AS employee(id, name, salary);
  21. +--------+---------+-------+
  22. |col_name|data_type|comment|
  23. +--------+---------+-------+
  24. | id| int| null|
  25. | name| string| null|
  26. | salary| double| null|
  27. +--------+---------+-------+
  28. -- Returns column metadata information for `TABLE` statement.
  29. DESC QUERY TABLE person;
  30. +--------+---------+----------+
  31. |col_name|data_type| comment|
  32. +--------+---------+----------+
  33. | name| string| null|
  34. | age| int| Agecolumn|
  35. | address| string| null|
  36. +--------+---------+----------+
  37. -- Returns column metadata information for a `FROM` statement.
  38. -- `QUERY` clause is optional and can be omitted.
  39. DESCRIBE FROM person SELECT age;
  40. +--------+---------+----------+
  41. |col_name|data_type| comment|
  42. +--------+---------+----------+
  43. | age| int| Agecolumn|
  44. +--------+---------+----------+