You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Gengliang Wang (Jira)" <ji...@apache.org> on 2019/09/09 09:59:00 UTC

[jira] [Commented] (SPARK-28068) `lag` second argument must be a literal

    [ https://issues.apache.org/jira/browse/SPARK-28068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16925540#comment-16925540 ] 

Gengliang Wang commented on SPARK-28068:
----------------------------------------

Is this ANSI SQL? From the specification 4.16 Data analysis operations (involving tables):
> The lead and lag functions each take three arguments, a <value expression> VE, an <exact numeric literal> OFFSET, and a <value expression> DEFAULT. 

> `lag` second argument must be a literal
> ---------------------------------------
>
>                 Key: SPARK-28068
>                 URL: https://issues.apache.org/jira/browse/SPARK-28068
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.0.0
>            Reporter: Dylan Guedes
>            Priority: Major
>
> Currently in Spark, `lag` (and, possible, some other window functions) requires the 2nd argument to be a literal.
> For example, this is not allowed:
> {code:sql}
> SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
> {code}
> However, this one works:
> {code:sql}
> SELECT lag(ten, 2) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10;
> {code}
> In comparison, Postgres accepts a literal as a 2nd argument. I found this issue while porting `window.sql` tests from Postgres to Spark



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

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