HyukjinKwon commented on code in PR #59416:
URL: https://github.com/apache/spark/pull/59416#discussion_r4272895856


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ViewResolution.scala:
##########
@@ -33,31 +35,54 @@ object ViewResolution {
     // operator.
 
     // Resolve all the UnresolvedRelations and Views in the child.
-    val newChild = AnalysisContext.withAnalysisContext(view.desc) {
+    val newChild = resolveInViewContext(view.desc, view.isTempView, view, 
view.child, resolveChild)
+
+    // Fail the analysis eagerly because outside AnalysisContext, the 
unresolved operators
+    // inside a view maybe resolved incorrectly.
+    checkAnalysis(newChild)
+
+    view.copy(child = newChild, options = options)
+  }
+
+  /**
+   * Resolves the source of a metric view read from the catalog. Like a view's 
child, it resolves
+   * in the catalog and namespace the metric view was created in, with its 
captured SQL configs.
+   */
+  def resolveMetricView(
+      metricView: MetricViewPlaceholder,
+      resolveChild: LogicalPlan => LogicalPlan,
+      checkAnalysis: LogicalPlan => Unit): MetricViewPlaceholder = {
+    val newChild = resolveInViewContext(

Review Comment:
   Thanks, the depth test and the useCurrentConfigsForView assertion now catch 
the regressions I listed. One gap remains in the config test. The metric view 
is created with every analysis config at its default, and only modified configs 
plus the time zone and ANSI are persisted, so nothing case-related is captured. 
The read then starts from a fresh SQLConf, which is case-insensitive anyway, so 
the test would still pass if the captured map were ignored. Could you create 
the metric view under a non-default analysis-time config and read it under a 
different session value? For example, use spark.sql.caseSensitive=true with a 
source whose columns differ only in case, or a non-default session time zone 
used by a timestamp expression in the WHERE.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4270849724","thread_id":"inline:4270849724","verdict_sha256":"4bff4292fa701b5775086d145dc3357f18af125bc192d05c3f1726f28f9f8a80"}
 -->



-- 
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]

Reply via email to