Skip to content

HIVE-28329: Fix vectorized col * CASE decimal multiply returning zero#6575

Open
kokila-19 wants to merge 1 commit into
apache:masterfrom
kokila-19:vector-fix
Open

HIVE-28329: Fix vectorized col * CASE decimal multiply returning zero#6575
kokila-19 wants to merge 1 commit into
apache:masterfrom
kokila-19:vector-fix

Conversation

@kokila-19

@kokila-19 kokila-19 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix HIVE-28329 in Vectorizer.java: preserve column inputs when re-instantiating DECIMAL multiply after DECIMAL_64→DECIMAL conversion and refresh projectedOutputColumns.
Added qtest vector_decimal64_col_multiply_case_subquery_join.q.

Why are the changes needed?

With CBO and vectorization enabled, expressions like col3 * CASE(...) are vectorized with the CASE as DECIMAL_64 and the multiply expecting DECIMAL. When fixDecimalDataTypePhysicalVariations() wraps the CASE with ConvertDecimal64ToDecimal and re-builds the multiply, the old code only used child expressions. So, col3 in inputColumnNum[] was dropped and a stale scratch column (often 0) was used instead.

That led to wrong multiply inputs and stale projectedOutputColumns, so HIVE-28329 returned 0.000000000 instead of 0.000197260.
Disabling vectorization avoided this broken path.

Does this PR introduce any user-facing change?

Yes, a bug fix. Affected queries now return correct decimal results. No new config or syntax.

How was this patch tested?

qtest: vector_decimal64_col_multiply_case_subquery_join.q
Manual test: EXPLAIN before/after to confirm multiply wiring col2, col19 vs col19, col9

@kokila-19 kokila-19 changed the title test fix HIVE-28329: Fix vectorized col * CASE decimal multiply returning zero Jul 7, 2026
@kokila-19 kokila-19 marked this pull request as ready for review July 7, 2026 08:08
Preserve inputColumnNum column refs when re-instantiating DECIMAL parents
after DECIMAL_64 child conversion and refresh projectedOutputColumns.
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

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