class BinaryArithmeticResolver extends TreeNodeResolver[BinaryArithmetic, Expression] with ProducesUnresolvedSubtree with CoercesExpressionTypes
BinaryArithmeticResolver is invoked by ExpressionResolver in order to resolve BinaryArithmetic nodes. During resolution, calling BinaryArithmeticWithDatetimeResolver and applying type coercion can result in BinaryArithmetic producing some other type of node or a subtree of nodes. In such cases a downwards traversal is necessary, but not going deeper than the original expression's children, since all nodes below that point are guaranteed to be already resolved.
For example, given a query:
SELECT '4 11:11' - INTERVAL '4 22:12' DAY TO MINUTE
BinaryArithmeticResolver is called for the following expression:
Subtract( Literal('4 11:11', StringType), Literal(Interval('4 22:12' DAY TO MINUTE), DayTimeIntervalType(0,2)) )
After calling BinaryArithmeticWithDatetimeResolver and applying type coercion, the expression is transformed into:
Cast( DatetimeSub( TimestampAddInterval( Literal('4 11:11', StringType), UnaryMinus( Literal(Interval('4 22:12' DAY TO MINUTE), DayTimeIntervalType(0,2)) ) ) ) )
A single Subtract node is replaced with a subtree of nodes. In order to resolve this subtree we need to invoke ExpressionResolver recursively on the top-most node's children. The top-most node itself is not resolved recursively in order to avoid recursive calls to BinaryArithmeticResolver and other sub-resolvers. To prevent a case where we resolve the same node twice, we need to mark nodes that will act as a limit for the downwards traversal by applying a ResolverTag.SINGLE_PASS_SUBTREE_BOUNDARY tag to them. These children along with all the nodes below them are guaranteed to be resolved at this point. When ExpressionResolver reaches one of the tagged nodes, it returns identity rather than resolving it. Finally, after resolving the subtree, we need to resolve the top-most node itself, which in this case means applying a timezone, if necessary.
- Alphabetic
- By Inheritance
- BinaryArithmeticResolver
- CoercesExpressionTypes
- ProducesUnresolvedSubtree
- ResolvesExpressionChildren
- TreeNodeResolver
- QueryErrorsBase
- DataTypeErrorsBase
- SQLConfHelper
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new BinaryArithmeticResolver(expressionResolver: ExpressionResolver)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val ansiTransformations: Transformations
- Attributes
- protected
- Definition Classes
- CoercesExpressionTypes
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def coerceExpressionTypes(expression: Expression, expressionTreeTraversal: ExpressionTreeTraversal): Expression
Coerces the expression types by applying necessary transformations on the expression and its children.
Coerces the expression types by applying necessary transformations on the expression and its children. Because fixed-point sometimes resolves type coercion in multiple passes, we apply each provided transformation twice, cyclically, to ensure that types are resolved. For example in a query like:
SELECT '1' + '1'
fixed-point analyzer requires two passes to resolve types.
In the end, we apply DefaultCollationTypeCoercion. See DefaultCollationTypeCoercion doc for more info.
Additionally, we copy the tags and origin in case the call to this method didn't come from ExpressionResolver, where they are copied generically.
- Definition Classes
- CoercesExpressionTypes
- def conf: SQLConf
The active config object within the current scope.
The active config object within the current scope. See SQLConf.get for more information.
- Definition Classes
- SQLConfHelper
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def getQueryContext(context: QueryContext): Array[QueryContext]
- Definition Classes
- DataTypeErrorsBase
- def getSummary(sqlContext: QueryContext): String
- Definition Classes
- DataTypeErrorsBase
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val nonAnsiTransformations: Transformations
- Attributes
- protected
- Definition Classes
- CoercesExpressionTypes
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def ordinalNumber(i: Int): String
- Definition Classes
- QueryErrorsBase
- def quoteByDefault(elem: String): String
- Attributes
- protected[sql]
- Definition Classes
- DataTypeErrorsBase
- def resolve(unresolvedBinaryArithmetic: BinaryArithmetic): Expression
- Definition Classes
- BinaryArithmeticResolver → TreeNodeResolver
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toDSOption(option: String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLConf(conf: String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLConfVal(conf: String): String
- Definition Classes
- QueryErrorsBase
- def toSQLExpr(e: Expression): String
- Definition Classes
- QueryErrorsBase
- def toSQLId(parts: Seq[String]): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLId(parts: String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLStmt(text: String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLType(t: AbstractDataType): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLType(text: String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(v: Any, t: DataType): String
- Definition Classes
- QueryErrorsBase
- def toSQLValue(value: Double): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: Float): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: Long): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: Int): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: Short): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: UTF8String): String
- Definition Classes
- DataTypeErrorsBase
- def toSQLValue(value: String): String
- Definition Classes
- DataTypeErrorsBase
- def toString(): String
- Definition Classes
- AnyRef → Any
- def tryPopSinglePassSubtreeBoundary(unresolvedExpression: Expression): Boolean
Try to pop the tag that marks the boundary of the single-pass subtree resolution.
Try to pop the tag that marks the boundary of the single-pass subtree resolution. ExpressionResolver calls this method to check if the subtree traversal needs to be stopped because lower subtree is already resolved.
- Attributes
- protected
- Definition Classes
- ProducesUnresolvedSubtree
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withResolvedChildren(unresolvedExpression: Expression, resolveChild: (Expression) => Expression): Expression
Resolves generic Expression children and returns its copy with children resolved.
Resolves generic Expression children and returns its copy with children resolved.
We avoid extra method calls here, because
resolveChildusually recurses deeply into resolution, and expression trees may be quite deep.- Attributes
- protected
- Definition Classes
- ResolvesExpressionChildren
- def withResolvedChildren(unresolvedExpression: QuaternaryExpression, resolveChild: (Expression) => Expression): Expression
Resolves QuaternaryExpression children and returns its copy with children resolved.
Resolves QuaternaryExpression children and returns its copy with children resolved.
- Attributes
- protected
- Definition Classes
- ResolvesExpressionChildren
- def withResolvedChildren(unresolvedExpression: TernaryExpression, resolveChild: (Expression) => Expression): Expression
Resolves TernaryExpression children and returns its copy with children resolved.
Resolves TernaryExpression children and returns its copy with children resolved.
- Attributes
- protected
- Definition Classes
- ResolvesExpressionChildren
- def withResolvedChildren(unresolvedExpression: BinaryExpression, resolveChild: (Expression) => Expression): Expression
Resolves BinaryExpression children and returns its copy with children resolved.
Resolves BinaryExpression children and returns its copy with children resolved.
- Attributes
- protected
- Definition Classes
- ResolvesExpressionChildren
- def withResolvedChildren(unresolvedExpression: UnaryExpression, resolveChild: (Expression) => Expression): Expression
Resolves UnaryExpression children and returns its copy with children resolved.
Resolves UnaryExpression children and returns its copy with children resolved.
- Attributes
- protected
- Definition Classes
- ResolvesExpressionChildren
- def withResolvedSubtree(expression: Expression, expressionResolver: (Expression) => Expression)(body: => Expression): Expression
Helper method used to resolve a subtree that is generated as part of the resolution of some node.
Helper method used to resolve a subtree that is generated as part of the resolution of some node. Method ensures that the downwards traversal never visits previously resolved nodes by tracking the limits of the traversal with a tag. Invokes a resolver callback to resolve children, but DOES NOT resolve the root of the subtree.
If the result of the callback is the same object as the source
expression, we don't perform the downwards traversal. This is both more optimal and a fail-safe mechanism in case we accidentally lose the ResolverTag.SINGLE_PASS_SUBTREE_BOUNDARY tag.- Attributes
- protected
- Definition Classes
- ProducesUnresolvedSubtree
- def withSQLConf[T](pairs: (String, String)*)(f: => T): T
Sets all SQL configurations specified in
pairs, callsf, and then restores all SQL configurations.Sets all SQL configurations specified in
pairs, callsf, and then restores all SQL configurations.- Attributes
- protected
- Definition Classes
- SQLConfHelper
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)