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, explicitMetadata: Option[Metadata] = scala.None) 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 BinaryExpression with Predicate with ExpectsInputTypes 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 AtLeastNNonNulls(n: Int, children: Seq[Expression]) extends Expression with Predicate with Product with Serializable

    A predicate that is evaluated to be true if there are at least n non-null values.

  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 BinaryExpression with Predicate

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

  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 NamedExpression 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 ExpectsInputTypes

  30. case class CaseKeyWhen(key: Expression, branches: Seq[Expression]) extends Expression with CaseWhenLike with Product with Serializable

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

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

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

  32. trait CaseWhenLike extends Expression

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

    Cast the child expression to the target data type.

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

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

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

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

    Combines the elements of two sets.

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

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

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

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

  42. case class CombineSum(child: Expression) extends AggregateExpression with Product with Serializable

    Sum should satisfy 3 cases: 1) sum of all null values = zero 2) sum for table column with no data = null 3) sum of column with null and not null values = sum of not null values Require separate CombineSum Expression and function as it has to distinguish "No data" case versus "data equals null" case, while aggregating results and at each partial expression.

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

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

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

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

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

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

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

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

    Returns the number of elements in the input set.

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

    Returns an Array containing the evaluation of all children expressions.

  51. case class CreateStruct(children: Seq[NamedExpression]) extends Expression with Product with Serializable

    Returns a Row containing the evaluation of all children expressions.

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

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

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

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

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

  56. trait ExpectsInputTypes extends AnyRef

    Expressions that require a specific DataType as input should implement this trait so that the proper type conversions can be performed in the analyzer.

  57. case class Explode(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.

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

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

  59. abstract class Expression extends TreeNode[Expression]

  60. trait ExtractValue extends UnaryExpression

  61. abstract class ExtractValueWithOrdinal extends UnaryExpression with ExtractValue

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

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

  64. sealed trait FrameBoundary extends AnyRef

    The trait used to represent the type of a Window Frame Boundary.

  65. sealed trait FrameType extends AnyRef

    The trait used to represent the type of a Window Frame.

  66. abstract class Generator extends Expression

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

  67. class GenericMutableRow extends GenericRow with MutableRow

  68. class GenericRow extends Row

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

  69. class GenericRowWithSchema extends GenericRow

  70. case class GetArrayItem(child: Expression, ordinal: Expression) extends ExtractValueWithOrdinal with Product with Serializable

    Returns the field at ordinal in the Array child

  71. case class GetArrayStructFields(child: Expression, field: StructField, ordinal: Int, containsNull: Boolean) extends UnaryExpression with ExtractValue with Product with Serializable

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

  72. case class GetMapValue(child: Expression, ordinal: Expression) extends ExtractValueWithOrdinal with Product with Serializable

    Returns the value of key ordinal in Map child

  73. case class GetStructField(child: Expression, field: StructField, ordinal: Int) extends UnaryExpression with ExtractValue with Product with Serializable

    Returns the value of fields in the Struct child.

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

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

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

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

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

    Evaluates to true if list contains value.

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

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

  81. class InterpretedProjection extends Projection

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

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

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

  84. class JoinedRow extends Row

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

  85. class JoinedRow2 extends Row

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

  86. class JoinedRow3 extends Row

    JIT HACK: Replace with macros

  87. class JoinedRow4 extends Row

    JIT HACK: Replace with macros

  88. class JoinedRow5 extends Row

    JIT HACK: Replace with macros

  89. class JoinedRow6 extends Row

    JIT HACK: Replace with macros

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

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

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

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

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

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

    Simple RegEx pattern matching function

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

    In order to do type checking, use Literal.

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

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

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

    Create a Decimal from an unscaled Long value

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

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

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

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

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

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

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

  106. final class MutableAny extends MutableValue

  107. final class MutableBoolean extends MutableValue

  108. final class MutableByte extends MutableValue

  109. final class MutableDouble extends MutableValue

  110. final class MutableFloat extends MutableValue

  111. final class MutableInt extends MutableValue

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

  113. final class MutableLong extends MutableValue

  114. abstract class MutableProjection extends Projection

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

  115. trait MutableRow extends Row

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

  116. final class MutableShort extends MutableValue

  117. abstract class MutableValue extends Serializable

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

  118. abstract class NamedExpression extends Expression

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

    Creates a new set of the specified type

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

  121. case class Or(left: Expression, right: Expression) extends BinaryExpression with Predicate with ExpectsInputTypes with Product with Serializable

  122. abstract class PartialAggregate extends AggregateExpression

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

  123. trait Predicate extends Expression

  124. trait PredicateHelper extends AnyRef

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

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

  127. abstract class RDG extends LeafExpression with Serializable

    A Random distribution generating expression.

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

  129. case class Rand(seed: Long = ...) extends RDG with Product with Serializable

    Generate a random column with i.

  130. case class Randn(seed: Long = ...) extends RDG with Product with Serializable

    Generate a random column with i.

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

  132. type Row = sql.Row

  133. class RowOrdering extends Ordering[Row]

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

    User-defined function.

  135. sealed abstract class SortDirection extends AnyRef

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

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

  138. case class SpecifiedWindowFrame(frameType: FrameType, frameStart: FrameBoundary, frameEnd: FrameBoundary) extends WindowFrame with Product with Serializable

    A specified Window Frame.

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

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

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

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

  142. trait StringComparison extends ExpectsInputTypes

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

  143. trait StringRegexExpression extends ExpectsInputTypes

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

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

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

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

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

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

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

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

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

  152. case class UnresolvedWindowExpression(child: UnresolvedWindowFunction, windowSpec: WindowSpecReference) extends UnaryExpression with Product with Serializable

  153. case class UnresolvedWindowFunction(name: String, children: Seq[Expression]) extends Expression with WindowFunction with Product with Serializable

  154. final class UnsafeFixedWidthAggregationMap extends AnyRef

  155. final class UnsafeRow extends MutableRow

  156. class UnsafeRowConverter extends AnyRef

    Converts Rows into UnsafeRow format.

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

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

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

  159. case class UserDefinedGenerator(elementTypes: Seq[(DataType, Boolean)], function: (Row) ⇒ TraversableOnce[Row], children: Seq[Expression]) extends Generator with Product with Serializable

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

  160. case class ValueFollowing(value: Int) extends FrameBoundary with Product with Serializable

    <value> FOLLOWING boundary.

  161. case class ValuePreceding(value: Int) extends FrameBoundary with Product with Serializable

    <value> PRECEDING boundary.

  162. case class WindowExpression(windowFunction: WindowFunction, windowSpec: WindowSpecDefinition) extends Expression with Product with Serializable

  163. sealed trait WindowFrame extends AnyRef

    The trait used to represent the a Window Frame.

  164. trait WindowFunction extends Expression

    Every window function needs to maintain a output buffer for its output.

  165. sealed trait WindowSpec extends AnyRef

    The trait of the Window Specification (specified in the OVER clause or WINDOW clause) for Window Functions.

  166. case class WindowSpecDefinition(partitionSpec: Seq[Expression], orderSpec: Seq[SortOrder], frameSpecification: WindowFrame) extends Expression with WindowSpec with Product with Serializable

    The specification for a window function.

  167. case class WindowSpecReference(name: String) extends WindowSpec with Product with Serializable

    A Window specification reference that refers to the WindowSpecDefinition defined under the name name.

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 CurrentRow extends FrameBoundary with Product with Serializable

    CURRENT ROW boundary.

  7. object Descending extends SortDirection with Product with Serializable

  8. object EmptyRow extends Row

    A row with no data.

  9. object ExtractValue

  10. object IntegerLiteral

    Extractor for retrieving Int literals.

  11. object InterpretedPredicate

  12. object Literal extends Serializable

  13. object NamedExpression

  14. object NonNullLiteral

    An extractor that matches non-null literal values

  15. object RangeFrame extends FrameType with Product with Serializable

    RangeFrame treats rows in a partition as groups of peers.

  16. val Row: sql.Row.type

  17. object RowFrame extends FrameType with Product with Serializable

    RowFrame treats rows in a partition individually.

  18. object RowOrdering extends Serializable

  19. object SpecifiedWindowFrame extends Serializable

  20. object UnboundedFollowing extends FrameBoundary with Product with Serializable

    UNBOUNDED FOLLOWING boundary.

  21. object UnboundedPreceding extends FrameBoundary with Product with Serializable

    UNBOUNDED PRECEDING boundary.

  22. object UnspecifiedFrame extends WindowFrame with Product with Serializable

    Used as a place holder when a frame specification is not defined.

  23. object VirtualColumn

  24. package codegen

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

  25. package mathfuncs

Inherited from AnyRef

Inherited from Any

Ungrouped