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 Abs(child: Expression) extends UnaryExpression with Product with Serializable

    A function that get the absolute value of the numeric value.

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

  3. case class AddItemToSet(item: Expression, set: Expression) extends Expression with Product with Serializable

    Adds an item to a set.

  4. abstract class AggregateExpression extends Expression

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

    A specific implementation of an aggregate function.

  6. 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.

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

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

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

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

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

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

  13. case class ArrayGetField(child: Expression, field: StructField, ordinal: Int, containsNull: Boolean) extends UnaryExpression with GetField with Product with Serializable

    Returns the array of value of fields in the Array of Struct child.

  14. abstract class Attribute extends NamedExpression

  15. class AttributeEquals extends AnyRef

    Attributes
    protected
  16. class AttributeMap[A] extends Map[Attribute, A] with Serializable

  17. case class AttributeReference(name: String, dataType: DataType, nullable: Boolean = true, metadata: Metadata = ...)(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.

  18. class AttributeSet extends Traversable[Attribute] with Serializable

    A Set designed to hold AttributeReference objects, that performs equality checking using expression id instead of standard java equality.

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

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

  21. abstract class BinaryArithmetic extends BinaryExpression

  22. abstract class BinaryComparison extends BinaryPredicate

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

  24. abstract class BinaryPredicate extends BinaryExpression with Predicate

  25. case class BitwiseAnd(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

    A function that calculates bitwise and(&) of two numbers.

  26. case class BitwiseNot(child: Expression) extends UnaryExpression with Product with Serializable

    A function that calculates bitwise not(~) of a number.

  27. case class BitwiseOr(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

    A function that calculates bitwise or(|) of two numbers.

  28. case class BitwiseXor(left: Expression, right: Expression) extends BinaryArithmetic with Product with Serializable

    A function that calculates bitwise xor(^) of two numbers.

  29. case class BoundReference(ordinal: Int, dataType: DataType, nullable: Boolean) extends Expression 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.

  30. trait CaseConversionExpression extends AnyRef

  31. 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".

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

    Cast the child expression to the target data type.

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

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

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

  36. case class CombineSets(left: Expression, right: Expression) extends BinaryExpression with Product with Serializable

    Combines the elements of two sets.

  37. case class CombineSetsAndCount(inputSet: Expression) extends AggregateExpression with Product with Serializable

  38. case class CombineSetsAndCountFunction(inputSet: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  39. case class CombineSetsAndSum(inputSet: Expression, base: Expression) extends AggregateExpression with Product with Serializable

  40. case class CombineSetsAndSumFunction(inputSet: Expression, base: AggregateExpression) extends AggregateFunction with Product with Serializable

  41. case class Contains(left: Expression, right: Expression) extends BinaryExpression with StringComparison with Product with Serializable

    A function that returns true if the string left contains the string right.

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

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

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

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

  46. case class CountSet(child: Expression) extends UnaryExpression with Product with Serializable

    Returns the number of elements in the input set.

  47. case class CreateArray(children: Seq[Expression]) extends Expression with Product with Serializable

    Returns an Array containing the evaluation of all children expressions.

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

  49. case class EndsWith(left: Expression, right: Expression) extends BinaryExpression with StringComparison with Product with Serializable

    A function that returns true if the string left ends with the string right.

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

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

  52. 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.

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

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

  54. abstract class Expression extends TreeNode[Expression]

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

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

  57. abstract class Generator extends Expression

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

  58. class GenericMutableRow extends GenericRow with MutableRow

  59. class GenericRow extends Row

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

  60. class GenericRowWithSchema extends GenericRow

  61. trait GetField extends UnaryExpression

  62. 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.

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

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

  65. case class GroupExpression(children: Seq[Expression]) extends Expression with Product with Serializable

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

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

    Evaluates to true if list contains value.

  68. case class InSet(value: Expression, hset: Set[Any]) extends Expression with Predicate with Product with Serializable

    Optimized version of In clause, when all filter values of In clause are static.

  69. case class InterpretedMutableProjection(expressions: Seq[Expression]) extends MutableProjection with Product with Serializable

    A MutableProjection that is calculated by calling eval on each of the specified expressions.

  70. class InterpretedProjection extends Projection

    A Projection that is calculated by calling the eval of each of the specified expressions.

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

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

  73. class JoinedRow extends Row

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

  74. class JoinedRow2 extends Row

    JIT HACK: Replace with macros The JoinedRow class is used in many performance critical situation.

  75. class JoinedRow3 extends Row

    JIT HACK: Replace with macros

  76. class JoinedRow4 extends Row

    JIT HACK: Replace with macros

  77. class JoinedRow5 extends Row

    JIT HACK: Replace with macros

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

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

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

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

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

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

    Simple RegEx pattern matching function

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

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

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

  86. case class MakeDecimal(child: Expression, precision: Int, scale: Int) extends UnaryExpression with Product with Serializable

    Create a Decimal from an unscaled Long value

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

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

  89. case class MaxOf(left: Expression, right: Expression) extends Expression with Product with Serializable

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

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

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

  93. final class MutableAny extends MutableValue

  94. final class MutableBoolean extends MutableValue

  95. final class MutableByte extends MutableValue

  96. final class MutableDouble extends MutableValue

  97. final class MutableFloat extends MutableValue

  98. final class MutableInt extends MutableValue

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

  100. final class MutableLong extends MutableValue

  101. abstract class MutableProjection extends Projection

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

  102. trait MutableRow extends Row

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

  103. final class MutableShort extends MutableValue

  104. abstract class MutableValue extends Serializable

    A parent class for mutable container objects that are reused when the values are changed, resulting in less garbage.

  105. abstract class NamedExpression extends Expression

  106. case class NewSet(elementType: DataType) extends LeafExpression with Product with Serializable

    Creates a new set of the specified type

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

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

  109. abstract class PartialAggregate extends AggregateExpression

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

  110. trait Predicate extends Expression

  111. trait PredicateHelper extends AnyRef

  112. case class PrettyAttribute(name: String) extends Attribute with LeafNode[Expression] with Product with Serializable

    A place holder used when printing expressions without debugging information such as the expression id or the unresolved indicator.

  113. abstract class Projection extends (Row) ⇒ Row

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

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

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

  116. type Row = sql.Row

  117. class RowOrdering extends Ordering[Row]

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

    User-defined function.

  119. sealed abstract class SortDirection extends AnyRef

  120. 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.

  121. final class SpecificMutableRow extends MutableRow

    A row type that holds an array specialized container objects, of type MutableValue, chosen based on the dataTypes of each column.

  122. 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.

  123. case class Sqrt(child: Expression) extends UnaryExpression with Product with Serializable

  124. case class StartsWith(left: Expression, right: Expression) extends BinaryExpression with StringComparison with Product with Serializable

    A function that returns true if the string left starts with the string right.

  125. trait StringComparison extends AnyRef

    A base trait for functions that compare two strings, returning a boolean.

  126. trait StringRegexExpression extends AnyRef

  127. case class StructGetField(child: Expression, field: StructField, ordinal: Int) extends UnaryExpression with GetField with Product with Serializable

    Returns the value of fields in the Struct child.

  128. case class Substring(str: Expression, pos: Expression, len: Expression) extends Expression with Product with Serializable

    A function that takes a substring of its first argument starting at a given position.

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

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

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

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

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

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

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

  136. case class UnscaledValue(child: Expression) extends UnaryExpression with Product with Serializable

    Return the unscaled Long value of a Decimal, assuming it fits in a Long

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

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

  138. case class UserDefinedGenerator(schema: Seq[Attribute], function: (Row) ⇒ TraversableOnce[Row], children: Seq[Expression]) extends Generator with Product with Serializable

    A generator that produces its output using the provided lambda function.

Value Members

  1. object Ascending extends SortDirection with Product with Serializable

  2. object AttributeMap extends Serializable

    Builds a map that is keyed by an Attribute's expression id.

  3. object AttributeSet extends Serializable

  4. object BindReferences extends Logging

  5. object Cast extends Serializable

  6. object Descending extends SortDirection with Product with Serializable

  7. object EmptyRow extends Row

    A row with no data.

  8. object IntegerLiteral

    Extractor for retrieving Int literals.

  9. object InterpretedPredicate

  10. object Literal extends Serializable

  11. object NamedExpression

  12. object NonNullLiteral

    An extractor that matches non-null literal values

  13. object Rand extends LeafExpression with Product with Serializable

  14. val Row: sql.Row.type

  15. object VirtualColumn

  16. package codegen

    A collection of generators that build custom bytecode at runtime for performing the evaluation of catalyst expression.

Inherited from AnyRef

Inherited from Any

Ungrouped