Skip to content

HIVE-30109: Iceberg: apply position deletes per batch - #6922

Open
deniskuzZ wants to merge 12 commits into
apache:masterfrom
deniskuzZ:HIVE-30109
Open

deniskuzZ wants to merge 12 commits into
apache:masterfrom
deniskuzZ:HIVE-30109

Conversation

@deniskuzZ

@deniskuzZ deniskuzZ commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

  • HiveDeleteFilter applies a data file's PositionDeleteIndex to a whole batch: it marks the deleted rows in the batch's position range and drops them from the selected rows
  • Removes the per-row path through Iceberg's DeleteFilter (HiveRow, HiveStructLike, HiveValueConverter, the IS_DELETED column)
  • Equality deletes are still rejected on the vectorized path, as before; row mode still reads them
  • Stacked on HIVE-30108: Iceberg: cache DVs and V2 position deletes in the LLAP metadata cache #6921 (HIVE-30108). This PR's own changes are its last three commits, 860aba4, 247ff0b and 006e935 (11 files, +253/-667)

Why are the changes needed?

Optimization. Local: 19.0 -> 1.32 ns/row at 7% scattered deletes (a local measurement of the delete filter; the harness is not part of this PR). Cluster, 1TRC part2 V2, 40 x r5d: these figures combine this PR with HIVE-30108 (and its cheaper delete-cache miss path): delete overhead 179.0 -> 29.4 s, part2 394.3 -> 263.1 s

Does this PR introduce any user-facing change?

No

How was this patch tested?

  • TestHiveDeleteFilter: random and ranged deletes, incoming selections, positions beyond the int range, an unknown row position
  • TestHiveIcebergVectorization now also runs V3; testRowIterator was removed with the per-row path
  • TestCachingDeleteLoader, TestHiveVectorizedReader, TestHiveIcebergCRUD#testPositionDeleteWithOrcRowFiltering
  • llap_iceberg_read_orc_deletes.q, llap_iceberg_read_orc.q, llap_iceberg_delete_cache.q (TestIcebergLlapLocalCliDriver)

…tadata cache

- Impact (cluster, 1TRC part2 V2, 40 x r5d): 711.9 s without the cache vs 394.3 s with it; hit rate 81-84%;
  local miss-path decode 235 -> 20 ns per record
- Compare hive.llap.io.cache.deletes case-insensitively, as HiveConf validates it (CachingDeleteLoader and the ACID
  reader)
- The best-effort metadata cache put no longer waits for memory: it evicts while that frees memory, then fails; the
  cache tag is computed inside the best-effort block
- TestCachingDeleteLoader: NONE level; the put that cannot reserve memory returns without an interrupt; drop the
  duplicated DV counters test and a duplicated assert
- CachingDeleteLoader validates a DV before reading or caching it, as BaseDeleteLoader does: a DV of another data
  file is rejected
- PositionDeletesReader reads ORC and Avro deletes with Deletes.toPositionIndexes instead of a copy of it
- hive.llap.io.cache.deletedeltas is no altName: getVar read it on every call, and Hadoop logged its deprecation in
  every process
- Keep hive.llap.io.cache.deletedeltas: the rename and its deprecation are reverted
- A data file that a position delete file does not reference gets no cache entry, counted as DELETE_CACHE_UNREFERENCED
- DELETE_CACHE_MISS counts the lookups that decode
- A partition-scoped position delete file caches its directory, the data files it references: a data file it does
  not list gets an empty index without a cache lookup, a decode or an entry of its own (DELETE_CACHE_UNREFERENCED)
- The query's directories are one map in the query's cache, fetched once per loader; the metadata cache keeps them
  across queries
- A directory is only published from a read of every row of the delete file: PositionDeletesReader returns the rows
  it read
- TestCachingDeleteLoader: directory eviction orders, a failed directory put, file-scoped delete files, a short read,
  concurrent reads with and without eviction and failed puts
- TestVectorizedOrcAcidRowBatchReaderTailCache sets the cache level in upper case, so it fails if
  VectorizedOrcAcidRowBatchReader stops lower-casing the level
- DeleteCacheLevel enum in org.apache.hadoop.hive.conf holds the hive.llap.io.cache.deletedeltas levels;
  HiveConf validates against it and both readers parse the setting with DeleteCacheLevel.of
- DeleteCacheLevel.of ignores case and maps a value that is not a level to NONE. Before, such a value
  turned the ACID cache off but left Iceberg at the metadata level
- TestHiveConf.testDeleteCacheLevel tests the parsing, so the reader tests set lower-case levels again;
  this undoes the ACID test change of Review comments 5
- CachingDeleteLoader: getOrReadDV, getOrReadPosDeletes and getOrDecodePosDeletes after BaseDeleteLoader's naming,
  findDirectory, and queryCache for the query's object cache
- LlapDeleteCache holds the metadata cache, cacheConf and the task context, which only exist together; the loader
  keeps one nullable field for it
- loadPositionDeletes, getOrReadPosDeletes and findDirectory return early instead of nesting ifs
- incrCounter replaces counter(...).increment, as in QueryFragmentCounters; putDirectory is removed
- shouldReadDeleteDeltasWithLlap takes the lowest cache level its caller needs instead of a boolean
- useLlapIo instead of useLlapCache in HiveIcebergInputFormat
- The constructors' javadoc says which loader uses the LLAP metadata cache; PositionDeletesReader's javadoc names the
  formats it reads
- CachingDeleteLoader spells PositionDeletes in full, as loadPositionDeletes and PositionDeletesReader do:
  getOrReadPositionDeletes, getOrDecodePositionDeletes, decodePositionDeletes; the test helper is writePositionDeletes
- Impact (local): 19.0 -> 1.32 ns/row; cluster (1TRC part2 V2, 40 x r5d, together with a cheaper delete-cache miss
  path): delete overhead 179.0 -> 29.4 s, part2 394.3 -> 263.1 s
- HiveVectorizedReader.reader: drop the unused readSchema parameter and the equality deletes TODO
- HiveDeleteFilter: drop the empty-batch guard (HiveBatchIterator ends the scan at an empty batch)
- TestHiveDeleteFilter: drop the loader tests, which TestCachingDeleteLoader covers
- testHiveDeleteFilterWithOrcRowFiltering runs on every format version
- DeletionVectors: keep the HIVE-30108 javadoc
- HiveVectorizedReader loads the deletes after the record reader is created, as before the change: LLAP IO reads the
  data meanwhile; a failed load closes the reader
- testFailedDeleteLoadClosesTheRecordReader; the V3 table with a DV is set up in one place
- testHiveDeleteFilterWithFilteredParquetBlock: keep the name and the Parquet only guard, parquet.block.size is its
  only lever
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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