Skip to content

[hive] Return null for array subscripts outside bounds - #11360

Open
zhangyue19921010 wants to merge 1 commit into
apache:masterfrom
zhangyue19921010:contrib/fix-hive-array-subscript-bounds
Open

zhangyue19921010 wants to merge 1 commit into
apache:masterfrom
zhangyue19921010:contrib/fix-hive-array-subscript-bounds

Conversation

@zhangyue19921010

Copy link
Copy Markdown
Contributor

Purpose

Fixes #11359.

Return NULL for array subscripts outside the bounds, matching Hive's standard list inspector. A direct projection such as SELECT arr[-1] FROM t currently fails on an ordinary append table when Hive evaluates the subscript against the Paimon list inspector.

Check the index before accessing the internal array. Valid elements, NULL arrays, and NULL elements keep their existing behavior.

Tests

  • HiveOnMrReadITCase#testArraySubscriptOutsideBounds: direct Hive query over an ordinary append table, including valid indices, negative and oversized indices, empty arrays, and NULL arrays. The query fails before the fix.
  • PaimonListObjectInspectorTest: actual Hive index UDF, standard-inspector comparison, integer boundary indices, generic and binary arrays, and NULL inputs.
    This run passed all nine scoped Maven tests (eight inspector cases and the direct SQL regression) with Checkstyle, Spotless, and Enforcer enabled. A separately compiled copy of the unchanged current-base inspector reproduces the direct SQL failure.

Validated with Hive 2.3.10 on JDK 11. An earlier broader run at the same final commit passed 49 tests, including all eight list-inspector cases and the direct SQL regression, with Checkstyle, Spotless, and Enforcer enabled. Three unchanged SerDe tests encountered Parquet classpath linkage errors; all three passed in a separate JUnit Platform run with matching Parquet 1.16.0 classes first. The affected module's source RAT check also passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Hive array subscripts outside bounds fail in direct projections

1 participant