Skip to content

CreateStruct Function Builder

CreateStruct is a function builder (e.g. Seq[Expression] => Expression) that can <> and is the <> of the <> function.

=== [[apply]] Creating CreateNamedStruct Expression -- apply Method

[source, scala]

apply(children: Seq[Expression]): CreateNamedStruct

NOTE: apply is part of Scala's https://www.scala-lang.org/api/2.11.12/index.html#scala.Function1[scala.Function1] contract to create a function of one parameter (e.g. Seq[Expression]).

apply creates a <> expression with the input children <> as follows:

  • For <> expressions that are <>, apply creates a pair of a <> expression (with the <> of the NamedExpression) and the NamedExpression itself

  • For <> expressions that are not <> yet, apply creates a pair of a NamePlaceholder expression and the NamedExpression itself

  • For all other <>, apply creates a pair of a <> expression (with the value as col[index]) and the Expression itself

apply is used when:

  • ResolveReferences logical resolution rule is requested to expandStarExpression

  • InConversion type coercion rule is requested to coerceTypes

  • ExpressionEncoder is requested to create an ExpressionEncoder for a tuple

  • Stack generator expression is requested to generate a Java source code

  • AstBuilder is requested to parse a struct and row constructor

  • ColumnStat is requested to statExprs

  • KeyValueGroupedDataset is requested to aggUntyped (when KeyValueGroupedDataset.agg typed operator is used)

  • <> typed transformation is used

  • <> standard function is used

  • SimpleTypedAggregateExpression expression is requested evaluateExpression and resultObjToRow