Skip to content

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

Merged
kasakrisz merged 1 commit into
apache:masterfrom
kokila-19:vector-fix
Jul 24, 2026
Merged

HIVE-28329: Fix vectorized col * CASE decimal multiply returning zero#6575
kasakrisz merged 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

Comment thread ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java Outdated
Comment thread ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java Outdated
Comment thread ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java Outdated
@kokila-19

Copy link
Copy Markdown
Contributor Author

There are sonar issues, I will work on resolving them and have green tests.

@kokila-19

Copy link
Copy Markdown
Contributor Author

@kasakrisz Sonar issues are not related to this PR.
Please review this when you can
Thank you !!

@kokila-19
kokila-19 requested a review from kasakrisz July 21, 2026 04:03

@kasakrisz kasakrisz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good left one question about testing with a simpler query.

Preserve inputColumnNum column refs when re-instantiating DECIMAL parents
after DECIMAL_64 child conversion and refresh projectedOutputColumns.
@sonarqubecloud

Copy link
Copy Markdown

@kasakrisz
kasakrisz merged commit c018fab into apache:master Jul 24, 2026
7 checks passed
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.

3 participants