feat(read): read identity partition columns from file scan tasks (#1068)

Data files imported from Hive may omit identity-partitioned source columns whose values are stored in the partition tuple. This PR carries each file’s writing spec through scan planning, JSON/REST tasks and splits, and supplies identity source constants to Parquet and Avro readers.

### Reading behavior

- Build a per-file `id_to_constant` map keyed by source field ID, using the task’s own historical `PartitionSpec`. Tasks constructed without a spec can still read physical columns. A supplied spec must match the file’s spec ID when present.
- Pass constants through the existing Avro and Parquet `Project` entry points and select them during recursive field projection, including primitive leaves of existing structs. Both formats use the projected Arrow type for nulls and for promotions such as decimal precision widening.
- Read the physical column, including stored nulls, when its field ID is present in the file. For a missing ID, use the identity partition value (including null) before name mapping or the initial default, following the [column projection rules](https://iceberg.apache.org/spec/#column-projection). Materialize constants before equality-delete evaluation, including columns needed by deletes but omitted from the output.
- Preserve upstream row-group filtering, filter binding and case sensitivity. Keep the original two-argument metrics filter interface unchanged; partition constants participate only in projection.

### Scope

Identity source columns only: bucket and other transforms do not reconstruct source values. `_partition`, `_spec_id` and `_file` are not added to this constant map. Nested/struct constant values and reconstruction of an entirely absent parent struct are outside this change. JSON tasks must retain the historical source-type information needed to decode partition values.

The reader flow follows Java’s `PartitionUtil.constantsMap`, `GenericReader` and recursive Parquet reader construction.
28 files changed
tree: d68e2b6a206fad07d4e65abe5bb4aadcc9426450
  1. .devcontainer/
  2. .github/
  3. ci/
  4. cmake_modules/
  5. dev/
  6. example/
  7. mkdocs/
  8. src/
  9. testing/
  10. thirdparty/
  11. .asf.yaml
  12. .clang-format
  13. .clang-tidy
  14. .gitignore
  15. .gitmodules
  16. .pre-commit-config.yaml
  17. AGENTS.md
  18. cmake-format.py
  19. CMakeLists.txt
  20. LICENSE
  21. Makefile
  22. NOTICE
  23. README.md
  24. requirements.txt
  25. SECURITY-THREAT-MODEL.md
README.md

Iceberg

Slack Ask DeepWiki License

Apache Iceberg™ C++

C++ implementation of Apache Iceberg™.

Requirements

Required:

  • C++23 compliant compiler (GCC 14+, Clang 18+, MSVC Build Tools 14.44+ (Visual Studio 2022 17.14+))
  • CMake 3.25+
  • Ninja (recommended build backend)

Optional:

Building and developing iceberg-cpp requires C++23. Applications linking against an installation built with ICEBERG_CXX20_COMPAT=ON may also use C++20 through the public-header compatibility layer. See Using the Library from C++20 for its scope.

Quick Start

git clone https://github.com/apache/iceberg-cpp.git
cd iceberg-cpp
cmake -S . -B build -G Ninja
cmake --build build
ctest --test-dir build --output-on-failure

Build with CMake

Build, Run Tests and Install Core Libraries

cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_STATIC=ON -DICEBERG_BUILD_SHARED=ON
cmake --build build
ctest --test-dir build --output-on-failure
cmake --install build

To run a specific test suite:

ctest --test-dir build -R schema_test --output-on-failure

verification_test runs the conformance fixtures from apache/iceberg-verification, pinned as a git submodule at testing/iceberg-verification. It is built only with -DICEBERG_BUILD_VERIFICATION_TESTS=ON, and CMake fails at configure time when the submodule is not checked out. To fetch it:

git submodule update --init testing/iceberg-verification

Pass -DICEBERG_VERIFICATION_DIR=/path/to/iceberg-verification to run against another checkout.

Build and Install Iceberg Bundle Library

Vendored Apache Arrow (default)

cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DICEBERG_BUILD_BUNDLE=ON
cmake --build build
ctest --test-dir build --output-on-failure
cmake --install build

Provided Apache Arrow

cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_PREFIX_PATH=/path/to/arrow -DICEBERG_BUILD_BUNDLE=ON
cmake --build build
ctest --test-dir build --output-on-failure
cmake --install build

CMake Build Options

OptionDefaultDescription
ICEBERG_BUILD_STATICONBuild static library
ICEBERG_BUILD_SHAREDOFFBuild shared library
ICEBERG_BUILD_TESTSONBuild tests
ICEBERG_BUILD_BUNDLEONBuild the battery-included library
ICEBERG_BUILD_RESTONBuild REST catalog client
ICEBERG_BUILD_REST_INTEGRATION_TESTSOFFBuild REST catalog integration tests
ICEBERG_BUILD_VERIFICATION_TESTSOFFBuild conformance tests over the apache/iceberg-verification fixtures
ICEBERG_SPDLOGONUse spdlog as the default logging backend
ICEBERG_BUILD_HIVEOFFBuild Hive (HMS) catalog client
ICEBERG_BUILD_SQL_CATALOGOFFBuild SQL catalog client
ICEBERG_SQL_SQLITEOFFBuild the SQLite connector for the SQL catalog
ICEBERG_SQL_POSTGRESQLOFFBuild the PostgreSQL connector for the SQL catalog
ICEBERG_SQL_MYSQLOFFBuild the MySQL connector for the SQL catalog
ICEBERG_ENABLE_ASANOFFEnable Address Sanitizer
ICEBERG_ENABLE_UBSANOFFEnable Undefined Behavior Sanitizer
ICEBERG_CXX20_COMPATOFFBuild a package with the C++20-compatible public API; library sources remain C++23

Build Examples

After installing the core libraries, you can build the examples:

cd example
cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/install
cmake --build build

If you are using provided Apache Arrow, include /path/to/arrow in CMAKE_PREFIX_PATH:

cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH="/path/to/install;/path/to/arrow"

The examples default to C++23. To compile an application as C++20, use a library installation built with ICEBERG_CXX20_COMPAT=ON and set the example standard:

cmake -S . -B build -G Ninja -DCMAKE_PREFIX_PATH=/path/to/compat-install -DICEBERG_EXAMPLE_CXX_STANDARD=20

Customizing Dependency URLs

If you experience network issues when downloading dependencies, you can customize the download URLs using environment variables:

  • ICEBERG_ARROW_URL: Apache Arrow tarball URL
  • ICEBERG_AVRO_URL: Apache Avro tarball URL
  • ICEBERG_AVRO_GIT_URL: Apache Avro git repository URL
  • ICEBERG_NANOARROW_URL: Nanoarrow tarball URL
  • ICEBERG_CROARING_URL: CRoaring tarball URL
  • ICEBERG_UTF8PROC_URL: utf8proc tarball URL
  • ICEBERG_NLOHMANN_JSON_URL: nlohmann-json tarball URL
  • ICEBERG_SPDLOG_URL: spdlog tarball URL
  • ICEBERG_CPR_URL: cpr tarball URL

Example:

export ICEBERG_ARROW_URL="https://your-mirror.com/apache-arrow-22.0.0.tar.gz"
cmake -S . -B build

Contribute

Apache Iceberg is an active open-source project, governed under the Apache Software Foundation (ASF). Iceberg-cpp is open to people who want to contribute to it. Here are some ways to get involved:

The Apache Iceberg community is built on the principles described in the Apache Way and all who engage with the community are expected to be respectful, open, come with the best interests of the community in mind, and abide by the Apache Foundation Code of Conduct.

In addition, contributors using AI-assisted tools must follow the documented guidelines for AI-assisted contributions available on the Iceberg website: https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions.

Linting

Install the python package pre-commit and run once pre-commit install.

pip install pre-commit
pre-commit install

This will setup a git pre-commit-hook that is executed on each commit and will report the linting problems. To run all hooks on all files use pre-commit run -a.

Dev Containers

We provide Dev Container configuration file templates.

To use a Dev Container as your development environment, follow the steps below, then select Dev Containers: Reopen in Container from VS Code's Command Palette.

cd .devcontainer
cp Dockerfile.template Dockerfile
cp devcontainer.json.template devcontainer.json

If you make improvements that could benefit all developers, please update the template files and submit a pull request.

License

Licensed under the Apache License, Version 2.0