lisancao commented on code in PR #59416:
URL: https://github.com/apache/spark/pull/59416#discussion_r4271765285
##########
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:
Added two tests in `MetricViewSuite`. One reads a metric view whose WHERE
only resolves case-insensitively with `spark.sql.caseSensitive=true`: it
succeeds with the captured config and fails with `useCurrentConfigsForView`.
The other reads a metric view over a view with the depth limit at 1: it raises
`VIEW_EXCEED_MAX_NESTED_DEPTH`, while reading the view directly passes. Both
fail without the fix, and the config test also fails with `isTempView = true`.
--
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]