Get column count of a hive table

Hi,

Is there any way to get the number of columns in HIVE ?

Thanks

Hi @jayanthireddy,

Below command will print the column counts in Hive table

describe your_database.your_table;

1 Like

Hi Abhinav, using describe command i can list all the columns of that table but not how many columns are there.

Hi @jayanthireddy,

It shows the count in “Fetched” property as shown in the below screenshot (Here it is showing 2 row, which means tables has two columns)

14 PM

We can also get the column count using below command

hive -S -e 'describe your_database_name.your_table_name' | wc -l

Just curious, are you trying to count the number of columns programmatically or you just want to see the count for your learning purpose.

2 Likes