Search code examples
hivehiveqlimpala

How to count the column in hive


I need the count of columns in hive ,So below is the example.

Table_name:emp

columns: empno, ename, manager, dept_id

Expected output: 4


Solution

  • Hive (now) supports the information_schema tables, so you could do:

    select count(*)
    from information_schema.columns
    where table_name = 'emp'