Skip to content

Commit

Permalink
rename parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-toth committed Apr 24, 2020
1 parent 686a827 commit 4a3ebf7
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,29 @@ object CTESubstitution extends Rule[LogicalPlan] {
*/
private def assertNoNameConflictsInCTE(
plan: LogicalPlan,
namesInChildren: Set[String] = Set.empty,
namesInExpressions: Set[String] = Set.empty): Unit = {
outerCTERelationNames: Set[String] = Set.empty,
namesInSubqueries: Set[String] = Set.empty): Unit = {
plan match {
case w @ With(child, relations) =>
val newNames = relations.map {
case (cteName, _) =>
if (namesInChildren.contains(cteName)) {
if (outerCTERelationNames.contains(cteName)) {
throw new AnalysisException(s"Name $cteName is ambiguous in nested CTE. " +
s"Please set ${LEGACY_CTE_PRECEDENCE_POLICY.key} to CORRECTED so that name " +
"defined in inner CTE takes precedence. If set it to LEGACY, outer CTE " +
"definitions will take precedence. See more details in SPARK-28228.")
} else {
cteName
}
}.toSet ++ namesInExpressions
assertNoNameConflictsInCTE(child, namesInChildren, newNames)
}.toSet ++ namesInSubqueries
assertNoNameConflictsInCTE(child, outerCTERelationNames, newNames)
w.innerChildren.foreach(assertNoNameConflictsInCTE(_, newNames, newNames))

case other =>
other.subqueries.foreach(
assertNoNameConflictsInCTE(_, namesInExpressions, namesInExpressions))
other.children.foreach(assertNoNameConflictsInCTE(_, namesInChildren, namesInExpressions))
assertNoNameConflictsInCTE(_, namesInSubqueries, namesInSubqueries))
other.children.foreach(
assertNoNameConflictsInCTE(_, outerCTERelationNames, namesInSubqueries))
}
}

Expand Down

0 comments on commit 4a3ebf7

Please sign in to comment.