SHOW TABLE EXTENDED

Description

SHOW TABLE EXTENDED will show information for all tables matching the given regular expression. Output includes basic table information and file system information like Last Access, Created By, Type, Provider, Table Properties, Location, Serde Library, InputFormat, OutputFormat, Storage Properties, Partition Provider, Partition Columns and Schema.

If a partition specification is present, it outputs the given partition’s file-system-specific information such as Partition Parameters and Partition Statistics. Note that a table regex cannot be used with a partition specification.

Syntax

  1. SHOW TABLE EXTENDED [ { IN | FROM } database_name ] LIKE regex_pattern
  2. [ partition_spec ]

Parameters

  • { IN|FROM } database_name

    Specifies database name. If not provided, will use the current database.

  • regex_pattern

    Specifies the regular expression pattern that is used to filter out unwanted tables.

    • Except for * and | character, the pattern works like a regular expression.
    • * alone matches 0 or more characters and | is used to separate multiple different regular expressions, any of which can match.
    • The leading and trailing blanks are trimmed in the input pattern before processing. The pattern match is case-insensitive.
  • partition_spec

    An optional parameter that specifies a comma separated list of key and value pairs for partitions. Note that a table regex cannot be used with a partition specification.

    Syntax: PARTITION ( partition_col_name = partition_col_val [ , ... ] )

Examples

  1. -- Assumes `employee` table created with partitioned by column `grade`
  2. CREATE TABLE employee(name STRING, grade INT) PARTITIONED BY (grade);
  3. INSERT INTO employee PARTITION (grade = 1) VALUES ('sam');
  4. INSERT INTO employee PARTITION (grade = 2) VALUES ('suj');
  5. -- Show the details of the table
  6. SHOW TABLE EXTENDED LIKE 'employee';
  7. +--------+---------+-----------+--------------------------------------------------------------+
  8. |database|tableName|isTemporary| information |
  9. +--------+---------+-----------+--------------------------------------------------------------+
  10. |default |employee |false |Database: default
  11. Table: employee
  12. Owner: root
  13. Created Time: Fri Aug 30 15:10:21 IST 2019
  14. Last Access: Thu Jan 01 05:30:00 IST 1970
  15. Created By: Spark 3.0.0-SNAPSHOT
  16. Type: MANAGED
  17. Provider: hive
  18. Table Properties: [transient_lastDdlTime=1567158021]
  19. Location: file:/opt/spark1/spark/spark-warehouse/employee
  20. Serde Library: org.apache.hadoop.hive.serde2.lazy
  21. .LazySimpleSerDe
  22. InputFormat: org.apache.hadoop.mapred.TextInputFormat
  23. OutputFormat: org.apache.hadoop.hive.ql.io
  24. .HiveIgnoreKeyTextOutputFormat
  25. Storage Properties: [serialization.format=1]
  26. Partition Provider: Catalog
  27. Partition Columns: [`grade`]
  28. Schema: root
  29. |-- name: string (nullable = true)
  30. |-- grade: integer (nullable = true)
  31. +--------+---------+-----------+--------------------------------------------------------------+
  32. -- showing the multiple table details with pattern matching
  33. SHOW TABLE EXTENDED LIKE 'employe*';
  34. +--------+---------+-----------+--------------------------------------------------------------+
  35. |database|tableName|isTemporary| information |
  36. +--------+---------+-----------+--------------------------------------------------------------+
  37. |default |employee |false |Database: default
  38. Table: employee
  39. Owner: root
  40. Created Time: Fri Aug 30 15:10:21 IST 2019
  41. Last Access: Thu Jan 01 05:30:00 IST 1970
  42. Created By: Spark 3.0.0-SNAPSHOT
  43. Type: MANAGED
  44. Provider: hive
  45. Table Properties: [transient_lastDdlTime=1567158021]
  46. Location: file:/opt/spark1/spark/spark-warehouse/employee
  47. Serde Library: org.apache.hadoop.hive.serde2.lazy
  48. .LazySimpleSerDe
  49. InputFormat: org.apache.hadoop.mapred.TextInputFormat
  50. OutputFormat: org.apache.hadoop.hive.ql.io
  51. .HiveIgnoreKeyTextOutputFormat
  52. Storage Properties: [serialization.format=1]
  53. Partition Provider: Catalog
  54. Partition Columns: [`grade`]
  55. Schema: root
  56. |-- name: string (nullable = true)
  57. |-- grade: integer (nullable = true)
  58. |default |employee1|false |Database: default
  59. Table: employee1
  60. Owner: root
  61. Created Time: Fri Aug 30 15:22:33 IST 2019
  62. Last Access: Thu Jan 01 05:30:00 IST 1970
  63. Created By: Spark 3.0.0-SNAPSHOT
  64. Type: MANAGED
  65. Provider: hive
  66. Table Properties: [transient_lastDdlTime=1567158753]
  67. Location: file:/opt/spark1/spark/spark-warehouse/employee1
  68. Serde Library: org.apache.hadoop.hive.serde2.lazy
  69. .LazySimpleSerDe
  70. InputFormat: org.apache.hadoop.mapred.TextInputFormat
  71. OutputFormat: org.apache.hadoop.hive.ql.io
  72. .HiveIgnoreKeyTextOutputFormat
  73. Storage Properties: [serialization.format=1]
  74. Partition Provider: Catalog
  75. Schema: root
  76. |-- name: string (nullable = true)
  77. +--------+---------+----------+---------------------------------------------------------------+
  78. -- show partition file system details
  79. SHOW TABLE EXTENDED IN default LIKE 'employee' PARTITION (grade=1);
  80. +--------+---------+-----------+--------------------------------------------------------------+
  81. |database|tableName|isTemporary| information |
  82. +--------+---------+-----------+--------------------------------------------------------------+
  83. |default |employee |false |Partition Values: [grade=1]
  84. Location: file:/opt/spark1/spark/spark-warehouse/employee
  85. /grade=1
  86. Serde Library: org.apache.hadoop.hive.serde2.lazy
  87. .LazySimpleSerDe
  88. InputFormat: org.apache.hadoop.mapred.TextInputFormat
  89. OutputFormat: org.apache.hadoop.hive.ql.io
  90. .HiveIgnoreKeyTextOutputFormat
  91. Storage Properties: [serialization.format=1]
  92. Partition Parameters: {rawDataSize=-1, numFiles=1,
  93. transient_lastDdlTime=1567158221, totalSize=4,
  94. COLUMN_STATS_ACCURATE=false, numRows=-1}
  95. Created Time: Fri Aug 30 15:13:41 IST 2019
  96. Last Access: Thu Jan 01 05:30:00 IST 1970
  97. Partition Statistics: 4 bytes
  98. |
  99. +--------+---------+-----------+--------------------------------------------------------------+
  100. -- show partition file system details with regex fails as shown below
  101. SHOW TABLE EXTENDED IN default LIKE 'empl*' PARTITION (grade=1);
  102. Error: Error running query: org.apache.spark.sql.catalyst.analysis.NoSuchTableException:
  103. Table or view 'emplo*' not found in database 'default'; (state=,code=0)