Skip to content

[AMORO-1304][Spark] Add read-only base store queries - #4563

Open
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/amoro1304-spark-base-store-20261203
Open

hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/amoro1304-spark-base-store-20261203

Conversation

@hutiefang76

@hutiefang76 hutiefang76 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Implements the Spark part of #1304.

A mixed-format table can be queried by merge on read or through its change store, but Spark cannot query table.base. This adds read-only batch access to the BaseStore, including retained-snapshot and timestamp queries, without reconstructing a historical merge of base and change data.

Brief change log

  • Resolve .base in the mixed, unified and session catalogs for Spark 3.3, 3.4 and 3.5.
  • Reuse Iceberg's reader through an adapter exposing read and metadata-column interfaces. Write, delete and row-level mutation interfaces are absent.
  • Load snapshot-specific schemas and convert Spark timestamp arguments from microseconds to milliseconds. Refresh base metadata before resolving snapshots and planning reads.
  • Document SQL/DataFrame access and the difference between base-store and merge-on-read results.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible
  • Add screenshots for manual tests if appropriate — not applicable
  • Run test locally before making a pull request

With JDK 11 and the repository's Maven 3.9.11 wrapper, ran clean verify for each Spark 3.3/3.4/3.5 profile and matching module, including dependencies. Each run executed 51 selected tests with no failures, errors or skips: the new BaseStore contracts and the neighboring TestSelectSQL, TestSessionCatalog and TestUnifiedCatalog tests.

Example for Spark 3.5:

./mvnw -Pspark-3.5 \
  -pl amoro-format-mixed/amoro-mixed-spark/v3.5/amoro-mixed-spark-3.5 -am \
  '-Dtest=*BaseStoreSQL,TestSelectSQL,TestSessionCatalog,TestUnifiedCatalog' \
  clean verify

The tests cover keyed/unkeyed tables, separate base/change contents, empty-table reads followed by writes, current and historical schemas, snapshot/timestamp selection, invalid history requests, and rejecting mutations while preserving the parent's rows and snapshot. They exercise named and session catalogs for both mixed Iceberg and mixed Hive. After extending the metadata assertion, reran the eight query/read-only cases per profile and verified _file against the committed data file and _pos against its row position; all passed without skips.

Before the change, the original SQL example failed on .base after its ordinary and .change controls passed. The separate unified-session regression also failed on historical reads before its routing fix. The documentation site was built with Hugo and the new section was checked in the rendered page.

The upstream Core/hadoop3 CI passed all five jobs on this head: Spark 3.3/3.4/3.5 with JDK 11, Spark 3.5 with JDK 17, and the Spark 4.1 optimizer with JDK 17. Maintainer review and merge are still pending.

The separate PR labeler run stopped at startup before creating any jobs; no run log is available. It did not execute tests.

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? Updated docs/engines/spark/spark-queries.md and added Javadocs for the read-only adapter.

AI assistance: DeepSeek V4 Pro contributed implementation and first-pass review; OpenAI Codex coordinated the work, corrected and reviewed the patch, ran validation, and prepared this description.

Expose the base store through Iceberg batch readers in Spark 3.3, 3.4
and 3.5, with snapshot and timestamp reads and preserved historical
schemas. Keep mutation interfaces out of the inspection table and
refresh metadata before resolving snapshots or planning reads.

Cover named and session catalogs for mixed Iceberg and mixed Hive,
including metadata columns and rejected mutations.

Generated-by: DeepSeek V4 Pro and OpenAI Codex

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant