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. abstract class Attribute extends NamedExpression

  14. class AttributeEquals extends AnyRef

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

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

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

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

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

  20. abstract class BinaryArithmetic extends BinaryExpression

  21. abstract class BinaryComparison extends BinaryPredicate

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

  23. abstract class BinaryPredicate extends BinaryExpression with Predicate

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

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

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

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

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

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

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

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

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

  29. trait CaseConversionExpression extends AnyRef

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

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

    Cast the child expression to the target data type.

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

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

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

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

    Combines the elements of two sets.

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

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

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

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

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

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

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

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

    Returns the number of elements in the input set.

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

    Returns an Array containing the evaluation of all children expressions.

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

  46. class DynamicRow extends GenericRow with Dynamic

    DynamicRows use scala's Dynamic trait to emulate an ORM of in a dynamically typed language.

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

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

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

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

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

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

  52. abstract class Expression extends TreeNode[Expression]

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

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

  55. abstract class Generator extends Expression

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

  56. class GenericMutableRow extends GenericRow with MutableRow

  57. class GenericRow extends Row

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

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

    Returns the value of fields in the Struct child.

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

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

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

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

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

    Evaluates to true if list contains value.

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

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

  66. class InterpretedProjection extends Projection

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

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

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

  69. class JoinedRow extends Row

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

  70. class JoinedRow2 extends Row

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

  71. class JoinedRow3 extends Row

    JIT HACK: Replace with macros

  72. class JoinedRow4 extends Row

    JIT HACK: Replace with macros

  73. class JoinedRow5 extends Row

    JIT HACK: Replace with macros

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

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

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

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

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

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

    Simple RegEx pattern matching function

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

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

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

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

    Create a Decimal from an unscaled Long value

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

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

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

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

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

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

  89. final class MutableAny extends MutableValue

  90. final class MutableBoolean extends MutableValue

  91. final class MutableByte extends MutableValue

  92. final class MutableDouble extends MutableValue

  93. final class MutableFloat extends MutableValue

  94. final class MutableInt extends MutableValue

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

  96. final class MutableLong extends MutableValue

  97. abstract class MutableProjection extends Projection

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

  98. trait MutableRow extends Row

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

  99. final class MutableShort extends MutableValue

  100. abstract class MutableValue extends Serializable

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

  101. abstract class NamedExpression extends Expression

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

    Creates a new set of the specified type

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

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

  105. abstract class PartialAggregate extends AggregateExpression

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

  106. trait Predicate extends Expression

  107. trait PredicateHelper extends AnyRef

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

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

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

  111. trait Row extends Seq[Any] with Serializable

    Represents one row of output from a relational operator.

  112. class RowOrdering extends Ordering[Row]

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

    User-defined function.

  114. sealed abstract class SortDirection extends AnyRef

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

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

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

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

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

  120. trait StringComparison extends AnyRef

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

  121. trait StringRegexExpression extends AnyRef

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

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

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

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

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

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

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

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

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

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

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

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

    Wrap a Row as a DynamicRow.

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 DynamicType extends DataType with Product with Serializable

    The data type representing DynamicRow values.

  8. object EmptyRow extends Row

    A row with no data.

  9. object IntegerLiteral

    Extractor for retrieving Int literals.

  10. object InterpretedPredicate

  11. object Literal extends Serializable

  12. object NamedExpression

  13. object Rand extends LeafExpression with Product with Serializable

  14. object Row extends Serializable

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