User Tools

Site Tools

A PCRE internal error occured. This might be caused by a faulty plugin

Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

part-count

====== PART_COUNT Function ====== PART_COUNT function returns the number partitions in the specified table. **Syntax**: <code language="sql"> PART_COUNT([db_name.]table_name, part_col=filter, ...); </code> **Parameters:** | [dbname.]table_name | Identifier, variable or expression | | part_col=filter | One or more partition filters | **Notes**: * HPL/SQL uses the following Hive statement to get the partition information: <code language="sql"> SHOW PARTITIONS db_name.tab_name [PARTITION (part_col=filter, ...)] </code> **Return Value:** * The number of partitions * NULL if the table does not exist or an error occurs **Return Type:** INT **Examples:** Table //db.orders// is partitioned by //dt// and //region// columns and has the following partitions: | dt=2015-09-01/region=1 | | dt=2015-09-01/region=2 | | dt=2015-09-02/region=1 | | dt=2015-09-03/region=3 | | dt=2015-09-03/region=2 | Get the total number of partitions: <code language="sql"> part_count(db.orders); -- 5 </code> Get the number of partitions in //region 1//: <code language="sql"> part_count(db.orders, region='1'); -- 2 </code> **Compatibility**: HPL/SQL extension. **Version:** HPL/SQL 0.3.13 See also: * [[part-count-by|PART_COUNT_BY]] - Get the number of partitions (group by) * [[part-loc|PART_LOC]] - Get the location of a partition