1-844-696-6465 (US)        +91 77600 44484        help@dezyre.com

count columns in Hive



0
Anyone know a query to count the number of columns in a table using a Hive QL?
Ex : if the table "t1" has columns c1,c2,c3...........cn (where n can be 200+), i want to know the number of columns using a hive QL, the output of the Hive QL should be columns=223.

2 Answer(s)


0

Hive columns you can find in metdata, which would be static based on the create command.
you can simple get the all column names the below command

hive -e "show create table $TABLE_NAME"


For a particular record, if you wanted to find columns then you have to read that record.


0

use below commands from shell:
>count = hive -S -e 'describe ' | wc -l;
>echo $count;

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password