You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Wan Kun (Jira)" <ji...@apache.org> on 2023/01/01 17:39:00 UTC

[jira] [Updated] (SPARK-41805) Reuse expressions in WindowSpecDefinition

     [ https://issues.apache.org/jira/browse/SPARK-41805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wan Kun updated SPARK-41805:
----------------------------
    Description: 
For complex expressions in window spec definition, we extract it and replace it with an AttributeReference (with an internal column name, e.g. "_w0").
We can reuse the extracted expressions to avoid generator unnecessary Window node.

For example: the logical plan of query
{code:sql}
SELECT max(value) over(partition by (key) order by cast(ts as timestamp)) as w1,
       min(value) over(partition by (key) order by cast(ts as timestamp)) as w2
FROM t1
{code}
contains two Window node.


  was:
For complex expressions in window spec definition, we extract it and replace it with an AttributeReference (with an internal column name, e.g. "_w0").
We can reuse the extracted expressions to avoid generator unnecessary Window node.

For example: the logical plan of query
{code:sql}
SELECT max(value) over(partition by (key) order by cast(ts as timestamp)) as w1,
               min(value) over(partition by (key) order by cast(ts as timestamp)) as w2
FROM t1
{code}
contains two Window node.



> Reuse expressions in WindowSpecDefinition
> -----------------------------------------
>
>                 Key: SPARK-41805
>                 URL: https://issues.apache.org/jira/browse/SPARK-41805
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.4.0
>            Reporter: Wan Kun
>            Priority: Major
>
> For complex expressions in window spec definition, we extract it and replace it with an AttributeReference (with an internal column name, e.g. "_w0").
> We can reuse the extracted expressions to avoid generator unnecessary Window node.
> For example: the logical plan of query
> {code:sql}
> SELECT max(value) over(partition by (key) order by cast(ts as timestamp)) as w1,
>        min(value) over(partition by (key) order by cast(ts as timestamp)) as w2
> FROM t1
> {code}
> contains two Window node.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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