[
https://issues.apache.org/jira/browse/FLINK-26764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18117903#comment-18117903
]
sepuri sai krishna commented on FLINK-26764:
--------------------------------------------
[~jark] you asked above whether LEAD and LAG ignore nulls in Flink SQL. I
measured it on 2.3.0, batch mode, with v = ('p', NULL, NULL, 'q') ordered by
ord:
{noformat}
LAG(v,1) NULL, p, NULL, NULL
LAG(v,1) RESPECT NULLS NULL, p, NULL, NULL
LAG(v,1) IGNORE NULLS NULL, p, NULL, NULL Spark 4.2.0: NULL, p,
p, p
LEAD(v,1) IGNORE NULLS NULL, NULL, q, NULL Spark 4.2.0: q, q, q,
NULL
{noformat}
So the clause is accepted and then has no effect on the result. LAG behaves the
same in streaming; LEAD is not supported in stream mode at all.
FIRST_VALUE and LAST_VALUE are the opposite case -- the clause is rejected
outright with "Cannot specify IGNORE NULLS or RESPECT NULLS following
'FIRST_VALUE'".
[~luoyuxia] are you still planning to pick this up? If not, I would like to
write up a design and take it through a FLIP. Happy to leave it with you if you
are.
> Support RESPECT NULLS for FIRST_VALUE/LAST_VALUE
> -------------------------------------------------
>
> Key: FLINK-26764
> URL: https://issues.apache.org/jira/browse/FLINK-26764
> Project: Flink
> Issue Type: New Feature
> Components: Table SQL / API, Table SQL / Planner
> Affects Versions: 2.1.0
> Reporter: luoyuxia
> Assignee: luoyuxia
> Priority: Major
> Labels: pull-request-available, stale-assigned
> Fix For: 2.4.0
>
>
> Flink supports fucntion FIRST_VALUE/LAST_VALUE, but the behavior is always
> ignore null value.
> But the
> [Spark|https://spark.apache.org/docs/2.4.2/api/sql/index.html#first_value],
> [Hive|https://cwiki.apache.org/confluence/display/hive/languagemanual+windowingandanalytics],
>
> [Oracle|https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions057.htm],
>
> [Snowflake|https://docs.snowflake.com/en/sql-reference/functions/first_value.html],
> etc, also support to respect null for FIRST_VALUE/LAST_VALUE.
> Should we also support to allow users to specifc whether to ignore null?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)