Skip to content
Advertisement

Count Number of Columns In Hive

I am looking for a way to count the number of columns in a table in Hive.

I know the following code works in Microsoft SQL Server. Is there a Hive equivalent?

SELECT COUNT(*),
  FROM INFORMATION_SCHEMA.COLUMNS
 WHERE TABLE_CATALOG = 'database_name'
   AND TABLE_SCHEMA = 'schema_name'
   AND TABLE_NAME = 'table_name'

Advertisement

Answer

try this

SHOW COLUMNS (FROM|IN) table_name [(FROM|IN) db_name]

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement