Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is is possible to count the number of partitions?

I am working on a test in which I must find out the number of partitions of a table and check if it is right. If I use show partitions TableName I get all the partitions by name, but I wish to get the number of partitions, like something along the lines show count(partitions) TableName (which retuns OK btw.. so it's not good) and get 12 (for ex.).
Is there any way to achieve this??

like image 477
diazazar Avatar asked Feb 18 '14 15:02

diazazar


People also ask

How do I count the number of partitions?

The number of partitions of n is given by the partition function p(n). So p(4) = 5. The notation λ ⊢ n means that λ is a partition of n. Partitions can be graphically visualized with Young diagrams or Ferrers diagrams.

Is there a formula for partitions?

A partition of a number is any combination of integers that adds up to that number. For example, 4 = 3+1 = 2+2 = 2+1+1 = 1+1+1+1, so the partition number of 4 is 5. It sounds simple, yet the partition number of 10 is 42, while 100 has more than 190 million partitions.

How many partitions of a set are there?

The 52 partitions of a set with 5 elements. A colored region indicates a subset of X that forms a member of the enclosing partition. Uncolored dots indicate single-element subsets. The first shown partition contains five single-element subsets; the last partition contains one subset having five elements.

How many partitions of 3 are there?

Hence the number 3 has 3 partitions: 3. 2+1. 1+1+1.


1 Answers

Using Hive CLI

$ hive --silent -e "show partitions <dbName>.<tableName>;" | wc -l

--silent is to enable silent mode

-e tells hive to execute quoted query string

like image 131
Viswa Murali Avatar answered Sep 17 '22 04:09

Viswa Murali