viirya commented on code in PR #37658:
URL: https://github.com/apache/spark/pull/37658#discussion_r958942534
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -1096,46 +1099,44 @@ class Analyzer(override val catalogManager:
CatalogManager)
case u @ UnresolvedTableOrView(identifier, cmd, allowTempView) =>
lookupTableOrView(identifier).map {
- case v: ResolvedView if v.isTemp && !allowTempView =>
+ case _: ResolvedTempView if !allowTempView =>
throw
QueryCompilationErrors.expectTableOrPermanentViewNotTempViewError(
- identifier.quoted, cmd, u)
+ identifier, cmd, u)
case other => other
}.getOrElse(u)
}
- private def lookupTempView(
- identifier: Seq[String],
- isStreaming: Boolean = false,
- isTimeTravel: Boolean = false): Option[LogicalPlan] = {
+ private def lookupTempView(identifier: Seq[String]):
Option[TemporaryViewRelation] = {
// We are resolving a view and this name is not a temp view when that
view was created. We
// return None earlier here.
if (isResolvingView && !isReferredTempViewName(identifier)) return None
+ v1SessionCatalog.getRawLocalOrGlobalTempView(identifier)
+ }
- val tmpView = identifier match {
- case Seq(part1) => v1SessionCatalog.lookupTempView(part1)
- case Seq(part1, part2) => v1SessionCatalog.lookupGlobalTempView(part1,
part2)
- case _ => None
- }
-
- tmpView.foreach { v =>
- if (isStreaming && !v.isStreaming) {
+ private def resolveTempView(
+ identifier: Seq[String],
+ isStreaming: Boolean = false,
+ isTimeTravel: Boolean = false): Option[LogicalPlan] = {
+ lookupTempView(identifier).map { v =>
+ val tempViewPlan = v1SessionCatalog.getTempViewRelation(v)
+ if (isStreaming && !tempViewPlan.isStreaming) {
throw
QueryCompilationErrors.readNonStreamingTempViewError(identifier.quoted)
}
if (isTimeTravel) {
- val target = if (v.isStreaming) "streams" else "views"
+ val target = if (tempViewPlan.isStreaming) "streams" else "views"
throw QueryCompilationErrors.timeTravelUnsupportedError(target)
}
+ tempViewPlan
}
- tmpView
}
/**
* Resolves relations to `ResolvedTable` or `ResolvedView`. This is for
resolving DDL and
Review Comment:
ResolvedView -> ResolvedTempView and ResolvedPersistentView
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]