Skip to content

[WIP]: HIVE-30043: Fix ClassCastException in FULL OUTER MapJoin with dynamic partitioned hash join - #6796

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

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

Conversation

@Indhumathi27

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

MapJoinDesc#getExprs() caches small-table value column names at compile time. For a FULL OUTER MapJoin using a dynamic partitioned hash join, a filter-tag value column can be appended to the small table's runtime value struct after that caching happens, shifting the positions of the columns that follow it. The cached column name then resolves to the wrong runtime field (and object inspector), producing a type mismatch on read.

This adds MapJoinOperator#correctSmallTableValueObjectInspectors(), invoked once from initializeOp() for FULL OUTER dynamic partitioned hash joins. It uses MapJoinDesc#getValueIndex(alias)
— a positional accessor into the same runtime struct that isn't affected by the shift — to correct the small table's field object inspectors in joinValuesStandardObjectInspectors (and, transitively, outputObjInspector), so downstream operators see the corrected types.

Since not every small-table alias in this join shape is guaranteed to have a ReduceSink KEY/VALUE-struct layout, the new getSmallTableStructFieldOI helper checks field existence via getAllStructFieldRefs() before use, rather than relying on StructObjectInspector#getStructFieldRef, which throws instead of returning null when the field isn't found.

Why are the changes needed?

Without this fix, the described query shape throws ClassCastException: LongWritable cannot be cast to ShortWritable (or an equivalent Writable type mismatch) during MapJoinOperator#closeOp → generateFullOuterSmallTableNoMatches, failing the query.

Does this PR introduce any user-facing change?

No

How was this patch tested?

test case added

@Indhumathi27 Indhumathi27 changed the title HIVE-30043: Fix ClassCastException in FULL OUTER MapJoin with dynamic… [WIP]: HIVE-30043: Fix ClassCastException in FULL OUTER MapJoin with dynamic partitioned hash join Sep 17, 2026
@sonarqubecloud

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