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

UnresolvedStar

UnresolvedStar Expression

UnresolvedStar is a Star expression that represents a star (i.e. all) expression in a logical query plan.

UnresolvedStar is created when:

UnresolvedStar can never be resolved, and is expanded at analysis (when ResolveReferences logical resolution rule is executed).

Note
UnresolvedStar can only be used in Project, Aggregate or ScriptTransformation logical operators.


Given UnresolvedStar can never be resolved it should not come as a surprise that it cannot be evaluated either (i.e. produce a value given an internal row). When requested to evaluate, UnresolvedStar simply reports a UnsupportedOperationException.

When created, UnresolvedStar takes name parts that, once concatenated, is the target of the star expansion.

Tip

Use star operator from Catalyst DSL’s expressions to create an UnresolvedStar.

You could also use $"" or ' to create an UnresolvedStar, but that requires sbt console (with Spark libraries defined in build.sbt) as the Catalyst DSL expressions implicits interfere with the Spark implicits to create columns.

Note

AstBuilder replaces count(*) (with no DISTINCT keyword) to count(1).

Star Expansion — expand Method

Note
expand is part of Star Contract to…​FIXME.

expand first expands to named expressions per target:

  • For unspecified target, expand gives the output schema of the input logical query plan (that assumes that the star refers to a relation / table)

  • For target with one element, expand gives the table (attribute) in the output schema of the input logical query plan (using qualifiers) if available

With no result earlier, expand then requests the input logical query plan to resolve the target name parts to a named expression.

For a named expression of StructType data type, expand creates an Alias expression with a GetStructField unary expression (with the resolved named expression and the field index).

expand reports a AnalysisException when:

  • The data type of the named expression (when the input logical plan was requested to resolve the target) is not a StructType.

  • Earlier attempts gave no results

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

关注公众号:spark技术分享

联系我们联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏