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

RuntimeReplaceable Contract

RuntimeReplaceable Contract — Replaceable SQL Expressions

RuntimeReplaceable is the marker contract for unary expressions that are replaced by Catalyst Optimizer with their child expression (that can then be evaluated).

Note
Catalyst Optimizer uses ReplaceExpressions logical optimization to replace RuntimeReplaceable expressions.

RuntimeReplaceable contract allows for expression aliases, i.e. expressions that are fairly complex in the inside than on the outside, and is used to provide compatibility with other SQL databases by supporting SQL functions with their more complex Catalyst expressions (that are already supported by Spark SQL).

Note
RuntimeReplaceables are tied up to their SQL functions in FunctionRegistry.

RuntimeReplaceable expressions cannot be evaluated (i.e. produce a value given an internal row) and therefore have to be replaced in the query execution pipeline.

Note
To make sure the explain plan and expression SQL works correctly, a RuntimeReplaceable implementation should override flatArguments and sql methods.
Table 1. RuntimeReplaceables
RuntimeReplaceable Standard Function SQL Function

IfNull

ifnull

Left

left

NullIf

nullif

Nvl

nvl

Nvl2

nvl2

ParseToDate

to_date

to_date

ParseToTimestamp

to_timestamp

to_timestamp

Right

right

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

关注公众号:spark技术分享

联系我们联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏