Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
anchovYu committed Aug 20, 2024
1 parent e5f6fbb commit 981917a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB
val DATA_TYPE_MISMATCH_ERROR = TreeNodeTag[Unit]("dataTypeMismatchError")
val INVALID_FORMAT_ERROR = TreeNodeTag[Unit]("invalidFormatError")

// Error that has a lower priority, that are not thrown immediately on triggering, e.g. certain
// internal errors. These errors are thrown at the end of the whole check analysis process.
var lowPriorityError: Option[() => Unit] = None
// Error that has a lower priority, that are not supposed to throw immediately on triggering,
// e.g. certain internal errors. These errors will be thrown at the end of the whole check
// analysis process, if no other error occurs.
var preemptedError: Option[SparkException] = None

/**
* Fails the analysis at the point where a specific tree node was parsed using a provided
Expand Down Expand Up @@ -118,16 +119,15 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB
private def checkNotContainingLCA(exprs: Seq[Expression], plan: LogicalPlan): Unit = {
exprs.foreach(_.transformDownWithPruning(_.containsPattern(LATERAL_COLUMN_ALIAS_REFERENCE)) {
case lcaRef: LateralColumnAliasReference =>
// this should be a low priority internal error that is thrown when no other error occurs
if (lowPriorityError.isEmpty) {
lowPriorityError = Some(
() =>
throw SparkException.internalError(
"Resolved plan should not contain any " +
s"LateralColumnAliasReference.\nDebugging information: plan:\n$plan",
context = lcaRef.origin.getQueryContext,
summary = lcaRef.origin.context.summary
)
// this should be a low priority internal error
if (preemptedError.isEmpty) {
preemptedError = Some(
SparkException.internalError(
"Resolved plan should not contain any " +
s"LateralColumnAliasReference.\nDebugging information: plan:\n$plan",
context = lcaRef.origin.getQueryContext,
summary = lcaRef.origin.context.summary
)
)
}
lcaRef
Expand Down Expand Up @@ -187,12 +187,15 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog with QueryErrorsB
case e: AnalysisException =>
throw new ExtendedAnalysisException(e, plan)
}
preemptedError = None
try {
checkAnalysis0(inlinedPlan)
lowPriorityError.foreach(_.apply())
preemptedError.foreach(throw _) // throw preempted error if any
} catch {
case e: AnalysisException =>
throw new ExtendedAnalysisException(e, inlinedPlan)
} finally {
preemptedError = None
}
plan.setAnalyzed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,14 @@ class LateralColumnAliasSuite extends LateralColumnAliasSuiteBase {
parameters = Map(
"objectName" -> "`Freq`",
"proposal" -> "`Percentage`, `group_counts`.`Group`"
)
),
context = ExpectedContext(
fragment = "Freq",
start = 280,
stop = 283)
)

// the states are cleared - a subsequent correct query should succeed
sql("select 1 as a, a").queryExecution.assertAnalyzed()
}
}

0 comments on commit 981917a

Please sign in to comment.