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


##########
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:
   The test now creates the metric view with the session time zone set to UTC 
and reads it in America/Los_Angeles. Its WHERE includes `hour(TIMESTAMP 
'2024-01-01 00:00:00 UTC') = 0`, which holds only at a zero offset, so the 
filter keeps rows only if the captured time zone is applied; with 
`useCurrentConfigsForView` it keeps none and the measure is NULL. The test 
fails if `resolveMetricView` ignores `viewSQLConfigs`.
   



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