[
https://issues.apache.org/jira/browse/HIVE-30136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hemanth Umashankar reassigned HIVE-30136:
-----------------------------------------
Assignee: (was: Hemanth Umashankar)
> 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
> Components: Vectorization
> Affects Versions: 4.3.0
> Reporter: Hemanth Umashankar
> Priority: Major
> Labels: pull-request-available
>
> With vectorization enabled, {{{}LAG{}}}/{{{}LEAD{}}} with a double-literal
> default returns {{0.0}} on rows that should use the default (e.g. the first
> row per partition for {{LAG}} with offset 1). With vectorization disabled,
> the same query returns the correct default.
> Suspected cause: {{VectorPTFEvaluatorAbstractLeadLag.initDefaultValue()}}
> always uses {{{}ConstantVectorExpression.getLongValue(){}}}. Double literals
> are stored in {{{}doubleValue{}}}, so {{longValue}} is 0.
> h3. Repro
> {code:sql}
> 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);
> -- Run the query below twice: once with =false, once with =true
> 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;
> {code}
> h3. Expected vs. actual
> Rows that should use the default (east/1 and west/1) show {{2.5}} with
> vectorization disabled, but {{0.0}} with vectorization enabled.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)