Packages

class 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. 5. Resolves the columns to SQL variables.

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
ColumnResolutionHelper, DataTypeErrorsBase, Rule[LogicalPlan], Logging, SQLConfHelper, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ResolveReferences
  2. ColumnResolutionHelper
  3. DataTypeErrorsBase
  4. Rule
  5. Logging
  6. SQLConfHelper
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ResolveReferences(catalogManager: CatalogManager)

Type Members

  1. implicit class LogStringContext extends AnyRef
    Definition Classes
    Logging

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. val catalogManager: CatalogManager
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  8. 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
  9. def containsStar(exprs: Seq[Expression]): Boolean

    Returns true if exprs contains a Star.

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

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

  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  15. def getQueryContext(context: QueryContext): Array[QueryContext]
    Definition Classes
    DataTypeErrorsBase
  16. def getSummary(sqlContext: QueryContext): String
    Definition Classes
    DataTypeErrorsBase
  17. 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.

  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  19. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  20. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  23. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  24. def logDebug(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  25. def logDebug(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  26. def logDebug(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  27. def logDebug(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  28. def logError(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  29. def logError(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  30. def logError(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  31. def logError(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  32. def logInfo(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  33. def logInfo(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  34. def logInfo(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  35. def logInfo(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  36. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  37. def logTrace(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  38. def logTrace(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  39. def logTrace(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  40. def logTrace(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  41. def logWarning(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  42. def logWarning(entry: LogEntry, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  43. def logWarning(entry: LogEntry): Unit
    Attributes
    protected
    Definition Classes
    Logging
  44. def logWarning(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  45. def lookupVariable(nameParts: Seq[String]): Option[VariableReference]

    Look up variable by nameParts.

    Look up variable by nameParts. If in SQL Script, first check local variables, unless in EXECUTE IMMEDIATE (EXECUTE IMMEDIATE generated query cannot access local variables). if not found fall back to session variables.

    nameParts

    NameParts of the variable.

    returns

    Reference to the variable.

    Definition Classes
    ColumnResolutionHelper
  46. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  47. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  48. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  49. def quoteByDefault(elem: String): String
    Attributes
    protected
    Definition Classes
    DataTypeErrorsBase
  50. def resolveAssignments(assignments: Seq[Assignment], mergeInto: MergeIntoTable, resolvePolicy: MergeResolvePolicy.Value): Seq[Assignment]
  51. def resolveColWithAgg(e: Expression, plan: LogicalPlan): Expression
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  52. def resolveColsLastResort(e: Expression): Expression

    The last resort to resolve columns.

    The last resort to resolve columns. Currently it does two things:

    • Try to resolve column names as outer references
    • Try to resolve column names as SQL variable
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  53. def resolveExprInAssignment(expr: Expression, hostPlan: LogicalPlan): Expression
    Definition Classes
    ColumnResolutionHelper
  54. def resolveExpressionByPlanChildren(e: Expression, q: LogicalPlan, includeLastResort: 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
  55. def resolveExpressionByPlanOutput(expr: Expression, plan: LogicalPlan, throws: Boolean = false, includeLastResort: 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
  56. 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
  57. def resolveLateralColumnAlias(selectList: Seq[Expression]): Seq[Expression]
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  58. def resolveOuterRef(e: Expression): Expression
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  59. def resolveVariables(e: Expression): Expression
    Attributes
    protected
    Definition Classes
    ColumnResolutionHelper
  60. lazy val ruleId: RuleId
    Attributes
    protected
    Definition Classes
    Rule
  61. 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
  62. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  63. def toDSOption(option: String): String
    Definition Classes
    DataTypeErrorsBase
  64. def toSQLConf(conf: String): String
    Definition Classes
    DataTypeErrorsBase
  65. def toSQLId(parts: Seq[String]): String
    Definition Classes
    DataTypeErrorsBase
  66. def toSQLId(parts: String): String
    Definition Classes
    DataTypeErrorsBase
  67. def toSQLStmt(text: String): String
    Definition Classes
    DataTypeErrorsBase
  68. def toSQLType(t: AbstractDataType): String
    Definition Classes
    DataTypeErrorsBase
  69. def toSQLType(text: String): String
    Definition Classes
    DataTypeErrorsBase
  70. def toSQLValue(value: Double): String
    Definition Classes
    DataTypeErrorsBase
  71. def toSQLValue(value: Float): String
    Definition Classes
    DataTypeErrorsBase
  72. def toSQLValue(value: Long): String
    Definition Classes
    DataTypeErrorsBase
  73. def toSQLValue(value: Int): String
    Definition Classes
    DataTypeErrorsBase
  74. def toSQLValue(value: Short): String
    Definition Classes
    DataTypeErrorsBase
  75. def toSQLValue(value: UTF8String): String
    Definition Classes
    DataTypeErrorsBase
  76. def toSQLValue(value: String): String
    Definition Classes
    DataTypeErrorsBase
  77. def toString(): String
    Definition Classes
    AnyRef → Any
  78. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  79. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  80. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  81. def withLogContext(context: Map[String, String])(body: => Unit): Unit
    Attributes
    protected
    Definition Classes
    Logging
  82. def withSQLConf[T](pairs: (String, String)*)(f: => T): T

    Sets all SQL configurations specified in pairs, calls f, and then restores all SQL configurations.

    Sets all SQL configurations specified in pairs, calls f, and then restores all SQL configurations.

    Attributes
    protected
    Definition Classes
    SQLConfHelper

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from ColumnResolutionHelper

Inherited from DataTypeErrorsBase

Inherited from Rule[LogicalPlan]

Inherited from Logging

Inherited from SQLConfHelper

Inherited from AnyRef

Inherited from Any

Ungrouped