Count Number of Columns In Hive

Viewed 25700

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'
5 Answers

Just do a describe it will show you all columns then at the bottom then you can see number of rows it fetched that is number of columns.

Related