uros-b commented on code in PR #60076:
URL: https://github.com/apache/spark/pull/60076#discussion_r4482299240
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -3860,6 +3866,49 @@ class Analyzer(
Project(windowOps.output ++ newExpressionsWithWindowFunctions, windowOps)
} // end of addWindow
+ /**
+ * Builds nested window dependencies above HAVING so it filters groups
before every window.
+ * Grouping helpers stay below the projection that separates HAVING from
window scope.
+ */
+ private def addWindowsWithHaving(
Review Comment:
Nested-window placement does not belong behind this flag.
`addWindowsWithHaving` duplicates #60090 (SPARK-60873), which already defaults
to Filter below every Window. If this PR lands first, SPARK-60873 stays broken
unless grouping-scope is enabled. If #60090 lands first, rebasing this opt-in
around that path would regress it. Land #60090 first; keep grouping helpers /
tags / QUALIFY hiding here, and do not re-gate HAVING-below-windows on this
config.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala:
##########
@@ -465,6 +465,17 @@ object SQLConf {
.intConf
.createWithDefault(100)
+ val HAVING_WITH_WINDOW_RESOLVES_GROUPING_COLUMN_FIRST =
+
buildConf("spark.sql.analyzer.havingWithWindowResolvesGroupingColumnFirst.enabled")
+ .internal()
+ .withBindingPolicy(ConfigBindingPolicy.SESSION)
+ .doc("When true, preserve HAVING name-resolution scope during window
extraction so that " +
+ "grouping columns take precedence over SELECT aliases. When false,
retain the legacy " +
+ "SELECT-alias precedence after window extraction.")
+ .version("4.4.0")
+ .booleanConf
+ .createWithDefault(false)
Review Comment:
Why are we not enabling this by default? It's a correctness fix
--
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]