关注 spark技术分享,
撸spark源码 玩spark最佳实践

WindowExpression

WindowExpression Unevaluable Expression

WindowExpression is an unevaluable expression that represents a window function (over some WindowSpecDefinition).

Note
An unevaluable expression cannot be evaluated to produce a value (neither in interpreted nor code-generated expression evaluations) and has to be resolved (replaced) to some other expressions or logical operators at analysis or optimization phases or they fail analysis.

WindowExpression is created when:

Note
WindowExpression can only be created with AggregateExpression, AggregateWindowFunction or OffsetWindowFunction expressions which is enforced at analysis.

Note
WindowExpression is resolved in ExtractWindowExpressions, ResolveWindowFrame and ResolveWindowOrder logical rules.

  1. Use sqlParser directly as in WithWindowDefinition Example

Table 1. WindowExpression’s Properties
Name Description

children

Collection of two expressions, i.e. windowFunction and WindowSpecDefinition, for which WindowExpression was created.

dataType

DataType of windowFunction

foldable

Whether or not windowFunction is foldable.

nullable

Whether or not windowFunction is nullable.

sql

"[windowFunction].sql OVER [windowSpec].sql"

toString

"[windowFunction] [windowSpec]"

Note
WindowExpression is subject to NullPropagation and DecimalAggregates logical optimizations.
Note
Distinct window functions are not supported which is enforced at analysis.
Note
An offset window function can only be evaluated in an ordered row-based window frame with a single offset which is enforced at analysis.

Catalyst DSL — windowExpr Operator

windowExpr operator in Catalyst DSL creates a WindowExpression expression, e.g. for testing or Spark SQL internals exploration.

Creating WindowExpression Instance

WindowExpression takes the following when created:

赞(0) 打赏
未经允许不得转载:spark技术分享 » WindowExpression
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏