镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[HIVE-30228]: Vectorized LEAD/LAG returns wrong default value when the default literal's type differs from the window column's type - #6933

Open
Indhumathi27 wants to merge 1 commit into
apache:masterfrom
Indhumathi27:HIVE-30228
Open

Indhumathi27 wants to merge 1 commit into
apache:masterfrom
Indhumathi27:HIVE-30228

Conversation

@Indhumathi27

@Indhumathi27 Indhumathi27 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Vectorized LEAD/LAG now correctly coerces the default value argument to the window column's type.

  • When the 3-arg form of lead/lag is used and the default value's type doesn't match the window column's type, a conversion cast is inserted and folded to a constant before vectorization.
  • The vectorized default-value reader now reads the constant using the accessor matching its actual type, instead of always treating it as a long, and throws if the type still doesn't match instead of silently misreading the value.

Why are the changes needed?

The default value in lead/lag wasn't being coerced to the column's type before vectorization — only the non-vectorized execution path handled that conversion at runtime. So a query like lag(mydate, 1, '1999-01-01') on a DATE column would read the string default incorrectly and silently return the wrong value (epoch 1970-01-01) instead of erroring or returning the correct default, causing vectorized and non-vectorized execution to disagree on the same query.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Testcase added

@Indhumathi27 Indhumathi27 changed the title [WIP] [HIVE-30228]: Vectorized LEAD/LAG returns wrong default value when the default literal's type differs from the window column's type [HIVE-30228]: Vectorized LEAD/LAG returns wrong default value when the default literal's type differs from the window column's type Nov 3, 2026
…ral's type differs from the window column's type
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants