[Hive - LanguageManual ] Windowing and Analytics Functions (待)
2015-01-26 12:18
459 查看
LanguageManual WindowingAndAnalytics
Skip to end of metadataAdded by Lefty Leverenz, last edited by Lefty Leverenz on Aug 01, 2014 (view change)
show comment
Go to start of metadata
Windowing and Analytics Functions
Windowing and Analytics FunctionsEnhancements to Hive QL
Examples
PARTITION BY with one partitioning column, no ORDER BY or window specification
PARTITION BY with two partitioning columns, no ORDER BY or window specification
PARTITION BY with one partitioning column, one ORDER BY column, and no window specification
PARTITION BY with two partitioning columns, two ORDER BY columns, and no window specification
PARTITION BY with partitioning, ORDER BY, and window specification
WINDOW clause
LEAD using default 1 row lead and not specifying default value
LAG specifying a lag of 3 rows and default value of 0
Enhancements to Hive QL
VersionIcon
Introduced in Hive version 0.11.
This section introduces the Hive QL enhancements for windowing and analytics functions. See "Windowing Specifications in HQL" (attached to HIVE-4197) for details. HIVE-896 has more information, including links to earlier documentation in the initial comments.
All of the windowing and analytics functions operate as per the SQL standard.
The current release supports the following functions for windowing and analytics:
Windowing functions
LEAD
The number of rows to lead can optionally be specified. If the number of rows to lead is not specified, the lead is one row.
Returns null when the lead for the current row extends beyond the end of the window.
LAG
The number of rows to lag can optionally be specified. If the number of rows to lag is not specified, the lag is one row.
Returns null when the lag for the current row extends before the beginning of the window.
FIRST_VALUE
LAST_VALUE
The OVER clause
OVER with standard aggregates:
COUNT
SUM
MIN
MAX
AVG
OVER with a PARTITION BY statement with one or more partitioning columns of any primitive datatype.
OVER with PARTITION BY and ORDER BY with one or more partitioning and/or ordering columns of any datatype.
OVER with a window specification. Windows can be defined separately in a WINDOW clause. Window specifications support these standard options:
ROWS ((CURRENT ROW) | (UNBOUNDED | [num]) PRECEDING) AND (UNBOUNDED | [num]) FOLLOWING
Icon
The OVER clause supports the following functions, but it does not support a window with them (see HIVE-4797):
Ranking functions: Rank, NTile, DenseRank, CumeDist, PercentRank.
Lead and Lag functions.
Analytics functions
RANK
ROW_NUMBER
DENSE_RANK
CUME_DIST
PERCENT_RANK
NTILE
Examples
This section provides examples of how to use the Hive QL windowing and analytics functions in SELECT statements. See HIVE-896 for additional examples.PARTITION BY with one partitioning column, no ORDER BY or window specification
PARTITION BY with two partitioning columns, no ORDER BY or window specification
PARTITION BY with one partitioning column, one ORDER BY column, and no window specification
PARTITION BY with two partitioning columns, two ORDER BY columns, and no window specification
PARTITION BY with partitioning, ORDER BY, and window specification
OVERclauses in a single query. A single
OVERclause only applies to the immediately preceding function call. In this example, the first OVER clause applies to COUNT(b) and the second OVER clause applies to SUM(b):
WINDOW clause
LEAD using default 1 row lead and not specifying default value
LAG specifying a lag of 3 rows and default value of 0
相关文章推荐
- Hive Windowing and Analytics Functions
- hive --Windowing and Analytics Functions
- [Hive - LanguageManual] Describe
- [HIve - LanguageManual] Subqueries
- [Hive - LanguageManual] Statistics in Hive
- Windowing Functions In Hive
- MySQL 5.7 Reference Manual Chapter 13 Functions and Operators 参考手册第十三章函数与操作符内容总结
- [HIve - LanguageManual] Sort/Distribute/Cluster/Order By
- [Hive - LanguageManual] Sampling
- [HIve - LanguageManual] Transform [没懂]
- [Hive - LanguageManual] VirtualColumns
- [Hive - LanguageManual] Archiving for File Count Reduction
- PHP - Manual手册 - XXXIII. Error Handling and Logging Functions错误处理和日志函数 - 概述
- Hive Analytics Functions row_number rank over partition by
- [Hive - LanguageManual] DML: Load, Insert, Update, Delete
- [HIve - LanguageManual] Hive Operators and User-Defined Functions (UDFs)
- [Hive - LanguageManual ] Explain (待)
- [HIve - LanguageManual] XPathUDF
- [Hive - LanguageManual] Hive Concurrency Model (待)
- MySQL - 翻译 - 5.1Reference Manual参考手册 - 11.6. Date and Time Functions日期和时间函数 - FROM_UNIXTIME将UNIX时间戳格式化为日期