You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Hemanth Umashankar (Jira)" <ji...@apache.org> on 2026/10/05 12:26:00 UTC
[jira] [Updated] (HIVE-30136) Fix vectorized LEAD/LAG literal defaults for DOUBLE/DECIMAL
[ https://issues.apache.org/jira/browse/HIVE-30136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hemanth Umashankar updated HIVE-30136:
--------------------------------------
Summary: Fix vectorized LEAD/LAG literal defaults for DOUBLE/DECIMAL (was: Vectorized LEAD/LAG uses wrong constant for DOUBLE/DECIMAL literal default (reads long 0))
> Fix vectorized LEAD/LAG literal defaults for DOUBLE/DECIMAL
> -----------------------------------------------------------
>
> Key: HIVE-30136
> URL: https://issues.apache.org/jira/browse/HIVE-30136
> Project: Hive
> Issue Type: Bug
> Reporter: Hemanth Umashankar
> Priority: Major
>
> With vectorization enabled, LAG/LEAD(..., ..., <double literal>) returns 0.0 on rows that need the default (e.g. first row per partition for LAG offset 1). With vectorization disabled, the same query returns the correct default.
> Suspected cause: VectorPTFEvaluatorAbstractLeadLag.initDefaultValue() always uses ConstantVectorExpression.getLongValue(); double literals use doubleValue, so longValue is 0.
> Repro:
> CREATE TABLE lag_default_repro (
> region STRING,
> sale_id INT,
> amount DOUBLE
> );
> INSERT INTO lag_default_repro VALUES
> ('east', 1, 10.0),
> ('east', 2, 20.0),
> ('west', 1, 100.0);
> SET hive.vectorized.execution.enabled=false;
> SELECT
> region,
> sale_id,
> amount,
> LAG(amount, 1, 2.5) OVER (PARTITION BY region ORDER BY sale_id) AS prev_amount_or_default
> FROM lag_default_repro
> ORDER BY region, sale_id;
> SET hive.vectorized.execution.enabled=true;
> SELECT
> region,
> sale_id,
> amount,
> LAG(amount, 1, 2.5) OVER (PARTITION BY region ORDER BY sale_id) AS prev_amount_or_default
> FROM lag_default_repro
> ORDER BY region, sale_id;
--
This message was sent by Atlassian Jira
(v8.20.10#820010)