Bruce Robbins created SPARK-38308:
-------------------------------------

             Summary: Select of a stream of window expressions fails
                 Key: SPARK-38308
                 URL: https://issues.apache.org/jira/browse/SPARK-38308
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.2.1, 3.1.3, 3.3.0
            Reporter: Bruce Robbins


The following query fails:
{noformat}
val df = spark.range(0, 20).map { x =>
  (x % 4, x + 1, x + 2)
}.toDF("a", "b", "c")

import org.apache.spark.sql.expressions._

val w = Window.partitionBy("a").orderBy("b")
val selectExprs = Stream(
  sum("c").over(w.rowsBetween(Window.unboundedPreceding, 
Window.currentRow)).as("sumc"),
  avg("c").over(w.rowsBetween(Window.unboundedPreceding, 
Window.currentRow)).as("avgc")
)

df.select(selectExprs: _*).show(false)
{noformat}
It fails with the following error:
{noformat}
org.apache.spark.sql.AnalysisException: Resolved attribute(s) avgc#23 missing 
from c#16L,a#14L,b#15L,sumc#21L in operator !Project [c#16L, a#14L, b#15L, 
sumc#21L, sumc#21L, avgc#23].;
{noformat}
If you change the Stream of window expressions to a Vector or List, the query 
succeeds.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to