org.apache.spark.sql.catalyst

expressions

package expressions

A set of classes that can be used to represent trees of relational expressions. A key goal of the expression library is to hide the details of naming and scoping from developers who want to manipulate trees of relational operators. As such, the library defines a special type of expression, a NamedExpression in addition to the standard collection of expressions.

Standard Expressions

A library of standard expressions (e.g., Add, EqualTo), aggregates (e.g., SUM, COUNT), and other computations (e.g. UDFs). Each expression type is capable of determining its output schema as a function of its children's output schema.

Named Expressions

Some expression are named and thus can be referenced by later operators in the dataflow graph. The two types of named expressions are AttributeReferences and Aliases. AttributeReferences refer to attributes of the input tuple for a given operator and form the leaves of some expression trees. Aliases assign a name to intermediate computations. For example, in the SQL statement SELECT a+b AS c FROM ..., the expressions a and b would be represented by AttributeReferences and c would be represented by an Alias.

During analysis, all named expressions are assigned a globally unique expression id, which can be used for equality comparisons. While the original names are kept around for debugging purposes, they should never be used to check if two attributes refer to the same value, as plan transformations can result in the introduction of naming ambiguity. For example, consider a plan that contains subqueries, both of which are reading from the same table. If an optimization removes the subqueries, scoping information would be destroyed, eliminating the ability to reason about which subquery produced a given attribute.

Evaluation

The result of expressions can be evaluated using the Expression.apply(Row) method.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. expressions
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class Add(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

  2. abstract class AggregateExpression extends Expression

  3. abstract class AggregateFunction extends AggregateExpression with Serializable with LeafNode[Expression]

    A specific implementation of an aggregate function.

  4. case class Alias(child: Expression, name: String)(exprId: ExprId = NamedExpression.newExprId, qualifiers: Seq[String] = immutable.this.Nil) extends NamedExpression with UnaryNode[Expression] with Product with Serializable

    Used to assign a new name to a computation.

  5. case class And(left: Expression, right: Expression) extends BinaryPredicate with Product with Serializable

  6. case class ApproxCountDistinct(child: Expression, relativeSD: Double = 0.05) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  7. case class ApproxCountDistinctMerge(child: Expression, relativeSD: Double) extends AggregateExpression with UnaryNode[Expression] with Product with Serializable

  8. case class ApproxCountDistinctMergeFunction(expr: Expression, base: AggregateExpression, relativeSD: Double) extends AggregateFunction with Product with Serializable

  9. case class ApproxCountDistinctPartition(child: Expression, relativeSD: Double) extends AggregateExpression with UnaryNode[Expression] with Product with Serializable

  10. case class ApproxCountDistinctPartitionFunction(expr: Expression, base: AggregateExpression, relativeSD: Double) extends AggregateFunction with Product with Serializable

  11. abstract class Attribute extends NamedExpression

  12. case class AttributeReference(name: String, dataType: DataType, nullable: Boolean = true)(exprId: ExprId = NamedExpression.newExprId, qualifiers: Seq[String] = immutable.this.Nil) extends Attribute with LeafNode[Expression] with Product with Serializable

    A reference to an attribute produced by another operator in the tree.

  13. case class Average(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  14. case class AverageFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  15. abstract class BinaryArithmetic extends BinaryExpression

  16. abstract class BinaryComparison extends BinaryPredicate

  17. abstract class BinaryExpression extends Expression with BinaryNode[Expression]

  18. abstract class BinaryPredicate extends BinaryExpression with Predicate

  19. class BindReferences[TreeNode <: QueryPlan[TreeNode]] extends Rule[TreeNode]

  20. case class BoundReference(ordinal: Int, baseReference: Attribute) extends Attribute with LeafNode[Expression] with Product with Serializable

    A bound reference points to a specific slot in the input tuple, allowing the actual value to be retrieved more efficiently.

  21. trait CaseConversionExpression extends AnyRef

  22. case class CaseWhen(branches: Seq[Expression]) extends Expression with Product with Serializable

    Case statements of the form "CASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END".

  23. case class Cast(child: Expression, dataType: DataType) extends UnaryExpression with Product with Serializable

    Cast the child expression to the target data type.

  24. case class Coalesce(children: Seq[Expression]) extends Expression with Product with Serializable

  25. case class Count(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  26. case class CountDistinct(expressions: Seq[Expression]) extends AggregateExpression with Product with Serializable

  27. case class CountDistinctFunction(expr: Seq[Expression], base: AggregateExpression) extends AggregateFunction with Product with Serializable

  28. case class CountFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  29. case class Divide(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

  30. class DynamicRow extends GenericRow with Dynamic

  31. case class EqualTo(left: Expression, right: Expression) extends BinaryComparison with Product with Serializable

  32. case class Explode(attributeNames: Seq[String], child: Expression) extends Generator with UnaryNode[Expression] with Product with Serializable

    Given an input array produces a sequence of rows for each value in the array.

  33. case class ExprId(id: Long) extends Product with Serializable

    A globally (within this JVM) id for a given named expression.

  34. abstract class Expression extends TreeNode[Expression]

  35. case class First(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  36. case class FirstFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  37. abstract class Generator extends Expression

    An expression that produces zero or more rows given a single input row.

  38. class GenericMutableRow extends GenericRow with MutableRow

  39. class GenericRow extends Row

    A row implementation that uses an array of objects as the underlying storage.

  40. case class GetField(child: Expression, fieldName: String) extends UnaryExpression with Product with Serializable

    Returns the value of fields in the Struct child.

  41. case class GetItem(child: Expression, ordinal: Expression) extends Expression with Product with Serializable

    Returns the item at ordinal in the Array child or the Key ordinal in Map child.

  42. case class GreaterThan(left: Expression, right: Expression) extends BinaryComparison with Product with Serializable

  43. case class GreaterThanOrEqual(left: Expression, right: Expression) extends BinaryComparison with Product with Serializable

  44. case class If(predicate: Expression, trueValue: Expression, falseValue: Expression) extends Expression with Product with Serializable

  45. case class In(value: Expression, list: Seq[Expression]) extends Expression with Predicate with Product with Serializable

    Evaluates to true if list contains value.

  46. case class IsNotNull(child: Expression) extends Expression with Predicate with UnaryNode[Expression] with Product with Serializable

  47. case class IsNull(child: Expression) extends Expression with Predicate with UnaryNode[Expression] with Product with Serializable

  48. class JoinedRow extends Row

    A mutable wrapper that makes two rows appear appear as a single concatenated row.

  49. abstract class LeafExpression extends Expression with LeafNode[Expression]

  50. case class LessThan(left: Expression, right: Expression) extends BinaryComparison with Product with Serializable

  51. case class LessThanOrEqual(left: Expression, right: Expression) extends BinaryComparison with Product with Serializable

  52. case class Like(left: Expression, right: Expression) extends BinaryExpression with StringRegexExpression with Product with Serializable

    Simple RegEx pattern matching function

  53. case class Literal(value: Any, dataType: DataType) extends LeafExpression with Product with Serializable

  54. case class Lower(child: Expression) extends UnaryExpression with CaseConversionExpression with Product with Serializable

    A function that converts the characters of a string to lowercase.

  55. case class Max(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  56. case class MaxFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  57. case class Min(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  58. case class MinFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  59. case class Multiply(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

  60. case class MutableLiteral(value: Any, nullable: Boolean = true) extends LeafExpression with Product with Serializable

  61. case class MutableProjection(expressions: Seq[Expression]) extends (Row) ⇒ Row with Product with Serializable

    Converts a Row to another Row given a sequence of expression that define each column of th new row.

  62. trait MutableRow extends Row

    An extended interface to Row that allows the values for each column to be updated.

  63. abstract class NamedExpression extends Expression

  64. trait NoBind extends AnyRef

    Used to denote operators that do their own binding of attributes internally.

  65. case class Not(child: Expression) extends UnaryExpression with Predicate with Product with Serializable

  66. case class Or(left: Expression, right: Expression) extends BinaryPredicate with Product with Serializable

  67. abstract class PartialAggregate extends AggregateExpression

    An AggregateExpression that can be partially computed without seeing all relevant tuples.

  68. trait Predicate extends Expression

  69. trait PredicateHelper extends AnyRef

  70. class Projection extends (Row) ⇒ Row

    Converts a Row to another Row given a sequence of expression that define each column of the new row.

  71. case class RLike(left: Expression, right: Expression) extends BinaryExpression with StringRegexExpression with Product with Serializable

  72. case class Remainder(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

  73. trait Row extends Seq[Any] with Serializable

    Represents one row of output from a relational operator.

  74. class RowOrdering extends Ordering[Row]

  75. case class ScalaUdf(function: AnyRef, dataType: DataType, children: Seq[Expression]) extends Expression with Product with Serializable

  76. sealed abstract class SortDirection extends AnyRef

  77. case class SortOrder(child: Expression, direction: SortDirection) extends Expression with UnaryNode[Expression] with Product with Serializable

    An expression that can be used to sort a tuple.

  78. case class SplitEvaluation(finalEvaluation: Expression, partialEvaluations: Seq[NamedExpression]) extends Product with Serializable

    Represents an aggregation that has been rewritten to be performed in two steps.

  79. trait StringRegexExpression extends AnyRef

  80. case class Subtract(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

  81. case class Sum(child: Expression) extends PartialAggregate with UnaryNode[Expression] with Product with Serializable

  82. case class SumDistinct(child: Expression) extends AggregateExpression with UnaryNode[Expression] with Product with Serializable

  83. case class SumDistinctFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  84. case class SumFunction(expr: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  85. abstract class UnaryExpression extends Expression with UnaryNode[Expression]

  86. case class UnaryMinus(child: Expression) extends UnaryExpression with Product with Serializable

  87. case class Upper(child: Expression) extends UnaryExpression with CaseConversionExpression with Product with Serializable

    A function that converts the characters of a string to uppercase.

  88. case class WrapDynamic(children: Seq[Attribute]) extends Expression with Product with Serializable

Value Members

  1. object Ascending extends SortDirection with Product with Serializable

  2. object BindReferences extends Logging

  3. object Descending extends SortDirection with Product with Serializable

  4. object DynamicType extends DataType with Product with Serializable

  5. object EmptyRow extends Row

    A row with no data.

  6. object IntegerLiteral

    Extractor for retrieving Int literals.

  7. object InterpretedPredicate

  8. object Literal extends Serializable

  9. object NamedExpression

  10. object Rand extends LeafExpression with Product with Serializable

  11. object Row extends Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped