Packages

object ResolveReferences extends Rule[LogicalPlan] with ColumnResolutionHelper

Resolves column references in the query plan. Basically it transform the query plan tree bottom up, and only try to resolve references for a plan node if all its children nodes are resolved, and there is no conflicting attributes between the children nodes (see hasConflictingAttrs for details).

The general workflow to resolve references: 1. Expands the star in Project/Aggregate/Generate. 2. Resolves the columns to AttributeReference with the output of the children plans. This includes metadata columns as well. 3. Resolves the columns to literal function which is allowed to be invoked without braces, e.g. SELECT col, current_date FROM t. 4. Resolves the columns to outer references with the outer plan if we are resolving subquery expressions.

Some plan nodes have special column reference resolution logic, please read these sub-rules for details:

Note: even if we use a single rule to resolve columns, it's still non-trivial to have a reliable column resolution order, as the rule will be executed multiple times, with other rules in the same batch. We should resolve columns with the next option only if all the previous options are permanently not applicable. If the current option can be applicable in the next iteration (other rules update the plan), we should not try the next option.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ResolveReferences
  2. ColumnResolutionHelper
  3. Rule
  4. Logging
  5. SQLConfHelper
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(plan: LogicalPlan): LogicalPlan
    Definition Classes
    ResolveReferencesRule
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. 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
  8. def containsStar(exprs: Seq[Expression]): Boolean

    Returns true if exprs contains a Star.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. def expandStarExpression(expr: Expression, child: LogicalPlan): Expression

    Expands the matching attribute.*'s in child's output.

  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def hasConflictingAttrs(p: LogicalPlan): Boolean

    Return true if there're conflicting attributes among children's outputs of a plan

    Return true if there're conflicting attributes among children's outputs of a plan

    The children logical plans may output columns with conflicting attribute IDs. This may happen in cases such as self-join. We should wait for the rule DeduplicateRelations to eliminate conflicting attribute IDs, otherwise we can't resolve columns correctly due to ambiguity.

  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  17. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  20. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  21. def logDebug(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  22. def logDebug(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  23. def logError(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  24. def logError(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  25. def logInfo(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  26. def logInfo(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  27. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  28. def logTrace(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  29. def logTrace(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  30. def logWarning(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  31. def logWarning(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  32. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  33. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  35. def resolveAssignments(assignments: Seq[Assignment], mergeInto: MergeIntoTable, resolvePolicy: ResolveReferences.MergeResolvePolicy.Value): Seq[Assignment]
  36. def resolveColWithAgg(e: Expression, plan: LogicalPlan): Expression
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  37. def resolveExpressionByPlanChildren(e: Expression, q: LogicalPlan, allowOuter: Boolean = false): Expression

    Resolves UnresolvedAttribute, GetColumnByOrdinal and extract value expressions(s) by the input plan's children output attributes.

    Resolves UnresolvedAttribute, GetColumnByOrdinal and extract value expressions(s) by the input plan's children output attributes.

    e

    The expression need to be resolved.

    q

    The LogicalPlan whose children are used to resolve expression's attribute.

    returns

    resolved Expression.

    Definition Classes
    ColumnResolutionHelper
  38. def resolveExpressionByPlanOutput(expr: Expression, plan: LogicalPlan, throws: Boolean = false, allowOuter: Boolean = false): Expression

    Resolves UnresolvedAttribute, GetColumnByOrdinal and extract value expressions(s) by the input plan's output attributes.

    Resolves UnresolvedAttribute, GetColumnByOrdinal and extract value expressions(s) by the input plan's output attributes. In order to resolve the nested fields correctly, this function makes use of throws parameter to control when to raise an AnalysisException.

    Example : SELECT * FROM t ORDER BY a.b

    In the above example, after a is resolved to a struct-type column, we may fail to resolve b if there is no such nested field named "b". We should not fail and wait for other rules to resolve it if possible.

    Definition Classes
    ColumnResolutionHelper
  39. def resolveExprsAndAddMissingAttrs(exprs: Seq[Expression], plan: LogicalPlan): (Seq[Expression], LogicalPlan)

    This method tries to resolve expressions and find missing attributes recursively.

    This method tries to resolve expressions and find missing attributes recursively. Specifically, when the expressions used in Sort or Filter contain unresolved attributes or resolved attributes which are missing from child output. This method tries to find the missing attributes and add them into the projection.

    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  40. def resolveLateralColumnAlias(selectList: Seq[Expression]): Seq[Expression]
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  41. def resolveOuterRef(e: Expression): Expression
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  42. lazy val ruleId: RuleId
    Attributes
    protected
    Definition Classes
    Rule
  43. val ruleName: String

    Name for this rule, automatically inferred based on class name.

    Name for this rule, automatically inferred based on class name.

    Definition Classes
    Rule
  44. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  45. def toString(): String
    Definition Classes
    AnyRef → Any
  46. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  48. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from ColumnResolutionHelper

Inherited from Rule[LogicalPlan]

Inherited from Logging

Inherited from SQLConfHelper

Inherited from AnyRef

Inherited from Any

Ungrouped