Skip to content

S3 tables engine - #113505

Merged
scanhex12 merged 11 commits into
masterfrom
s3_tables
Aug 13, 2026
Merged

scanhex12 merged 11 commits into
masterfrom
s3_tables

Conversation

@scanhex12

@scanhex12 scanhex12 commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

S3 tables engine catalog for datalakes. Same as #103220, but with working INSERT

Version info

  • Merged into: 26.8.1.1361 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c3afc91]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, s3 storage, parallel, 2/3) FAIL
04509_hash_table_sizes_stats_table_functions FAIL cidb

AI Review

Summary

This PR adds catalog_type = 's3tables' to DataLakeCatalog, with SigV4-authenticated S3 Tables REST access, bucket-root Iceberg locations, and S3 write-path tweaks for INSERT. The current head still has unresolved contract gaps in the AWS auth path, the create/drop behavior, and the source-registered docs, so I would block merge until those are fixed and covered.

PR Metadata
  • Changelog category: New Feature matches the change.
  • Changelog entry is required, but the current text is not user-readable: it relies on another PR link and "working INSERT" shorthand instead of describing user-visible behavior.
  • Suggested replacement: Adds support for the s3tablescatalog type inDataLakeCatalog, allowing ClickHouse to read and write Iceberg tables through the Amazon S3 Tables Iceberg REST endpoint.
Findings
  • ❌ Blockers
    • [src/Databases/DataLake/S3TablesCatalog.h:26, src/Databases/DataLake/RestCatalog.cpp:1711-1737] S3TablesCatalog still inherits the generic RestCatalog::createTable request shape, which always sends stage-create = false. Amazon S3 Tables documents that the stage-create option is unsupported and returns 400 Bad Request, so the newly exposed write path is still not proven to support plain CREATE TABLE / CTAS. Suggested fix: override createTable for s3tables and emit only the request fields the S3 Tables REST endpoint accepts.
    • [src/Storages/ObjectStorage/StorageObjectStorage.cpp:875-880] After S3TablesCatalog::dropTable purge-deletes the table bucket, StorageObjectStorage::drop still unconditionally runs the generic Iceberg cleanup. The Iceberg drop path starts with a bucket listing, so a successful destructive DROP TABLE can still surface as a user-visible exception after the table is already gone. Suggested fix: skip configuration->drop for s3tables, or make the Iceberg drop path treat a missing bucket after catalog-side purge as success.
  • ⚠️ Majors
    • [src/Databases/DataLake/S3TablesCatalog.cpp:75-79] CatalogSettings already carries aws_external_id, and the docs now advertise it, but S3TablesCatalog never forwards it into DB::S3::CredentialsConfiguration. Any cross-account role that enforces sts:ExternalId will reject the AssumeRole call, so a documented CREATE DATABASE ... SETTINGS aws_role_arn='...', aws_external_id='...' configuration still cannot authenticate. Suggested fix: set creds_config.external_id = catalog_settings_.aws_external_id. [dismissed by author -- https://github.com/S3 tables engine #113505#discussion_r3764784279]
    • [src/Databases/DataLake/S3TablesCatalog.cpp:184-204, src/Databases/DataLake/DatabaseDataLake.cpp:776, 909-915] The current fallback still materializes a one-shot S3Credentials snapshot for vended_credentials = 0, while DatabaseDataLake only keeps refresh callbacks for GLUE. That means STS / IRSA / IMDS credentials will be refreshed between table opens, but not after the storage object has been built, so long reads and inserts can still fail on ExpiredToken. Suggested fix: treat s3tables as a provider-chain-managed catalog like GLUE, and return a refresh callback that re-reads credentials_provider instead of baking the current session into engine args. [dismissed by author -- https://github.com/S3 tables engine #113505#discussion_r3764784284]
  • 💡 Nits
    • [src/Databases/DataLake/DatabaseDataLake.cpp:1668-1716] The source-registered DataLakeCatalog docs still list supported catalog_type values only through delta_sharing and give no S3 Tables-specific guidance such as warehouse being the table-bucket ARN. Because these strings feed the generated docs, users are still told that s3tables is unsupported. Suggested fix: update the source doc block in the same PR. [dismissed by author -- https://github.com/S3 tables engine #113505#discussion_r3765717169]
Tests
  • ⚠️ The diff adds a new s3tables catalog implementation but no focused regression coverage. At minimum, add one integration test that proves the advertised CREATE DATABASE ... catalog_type='s3tables' -> CREATE TABLE -> INSERT -> SELECT -> DROP TABLE flow, and one auth-path test for either aws_external_id or temporary AWS credentials refreshing after expiry.
Final Verdict
  • Status: ❌ Block
  • Minimum required actions:
    1. Fix the remaining create/drop correctness gaps in the s3tables path.
    2. Thread aws_external_id and restore long-lived AWS credential refresh for non-vended auth.
    3. Update the source-registered docs and add focused regression coverage for the feature.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.10% 79.10% +0.00%

Changed lines: Changed C/C++ lines covered: 93/370 (25.14%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Aug 5, 2026

/// Iceberg REST catalog for Amazon S3 Tables (SigV4, signing name `s3tables`).
/// https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-open-source.html
class S3TablesCatalog final : public RestCatalog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S3TablesCatalog inherits RestCatalog::createTable unchanged, so CREATE TABLE still sends the generic Iceberg REST payload with stage-create = false (RestCatalog::createTable sets it unconditionally at src/Databases/DataLake/RestCatalog.cpp:1736). Amazon S3 Tables rejects any stage-create option on CreateTable with 400 Bad Request, so this catalog type will still fail on plain CREATE TABLE / CTAS even after the SigV4 work lands. This needs an S3 Tables-specific createTable override that omits that field before we expose the catalog as supporting writes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWS: "The stage-create option is not supported […] This means you cannot create a table from query results using CREATE TABLE AS SELECT (CTAS)"

}
/// We cannot use query context here, because drop is executed in the background.
configuration->drop(Context::getGlobalContextInstance());
configuration->drop(drop_context);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After s3tables now purge-deletes the table bucket in catalog->dropTable(..., true), this unconditional second phase still runs the generic Iceberg cleanup. IcebergMetadata::drop starts by listFiles(*object_storage, persistent_components.table_path, ...) at src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp:1486, and on S3 that becomes ListObjectsV2 with throwIfError(...) on any NoSuchBucket at src/Disks/DiskObjectStorage/ObjectStorages/S3/S3ObjectStorage.cpp:371-372. So a successful purge can still surface as a user-visible DROP TABLE exception after the destructive work already happened. We need to skip configuration->drop for s3tables (or make the Iceberg drop path tolerate a missing bucket after catalog-side purge).

@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c3afc9190 with master c42c154da (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 691.73 MiB 688.77 MiB -2.96 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes ⚠️

65 object files changed (+436.63 KiB total), 2 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Databases/DataLake/S3TablesCatalog.cpp.o new 320.40 KiB +320.40 KiB
src/CMakeFiles/dbms.dir/Databases/DataLake/AWSV4Signer.cpp.o new 66.27 KiB +66.27 KiB
src/CMakeFiles/clickhouse_common_io.dir/IO/S3/URI.cpp.o 106.20 KiB 142.43 KiB +36.23 KiB (+34.12%)

737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1880 translation units recompiled, 14176 s compile time in total, 1878 of them have a recent master baseline.

Translation units without a recent master baseline:

  • src/Databases/DataLake/S3TablesCatalog.cpp: 12.7 s

Job report

case DB::DatabaseDataLakeCatalogType::S3_TABLES:
{
#if USE_AWS_S3 && USE_SSL
catalog_impl = std::make_shared<DataLake::S3TablesCatalog>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables catalog_type = 's3tables' in the live DataLakeCatalog path, but the PR still ships with no focused coverage for the feature-specific contract. There are no tests in the diff for the CREATE DATABASE ... catalog_type='s3tables' flow, CREATE/INSERT/SELECT/DROP TABLE, or the AWS-specific auth paths introduced here (aws_external_id, temporary credential refresh, iceberg_delete_data_on_drop). Given how much behavior diverges from generic RestCatalog, I don't think the advertised "working INSERT" claim is proven yet without at least one focused integration test and one auth-path regression test.

@scanhex12

Copy link
Copy Markdown
Member Author

I'll merge this PR as most of the work was done in parent PR. I just reviewed it and added support for inserts

@scanhex12
scanhex12 enabled auto-merge August 13, 2026 18:12
@scanhex12
scanhex12 added this pull request to the merge queue Aug 13, 2026
Merged via the queue into master with commit ba6a424 Aug 13, 2026
180 of 182 checks passed
@scanhex12
scanhex12 deleted the s3_tables branch August 13, 2026 18:45
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants