Skip to content

fix(iceberg): too many open partitions by sorting inserts - #3294

Merged
kukushking merged 2 commits into
aws:mainfrom
knQzx:fix-iceberg-partition-limit
Apr 7, 2026
Merged

kukushking merged 2 commits into
aws:mainfrom
knQzx:fix-iceberg-partition-limit

Conversation

@knQzx

@knQzx knQzx commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • adds ORDER BY on partition columns to the INSERT INTO ... SELECT query in _merge_iceberg
  • this lets iceberg close partition writers sequentially instead of keeping all of them open at once, preventing the ICEBERG_TOO_MANY_OPEN_PARTITIONS error
  • handles partition transform functions like day(ts) by extracting the underlying column name for ordering

Test plan

  • added unit tests for _extract_column_from_partition_transform and _build_order_by_clause helper functions
  • tested plain columns, transform functions (day, truncate), empty/none partition lists
  • existing integration tests with partition_cols parameter cover the end-to-end flow

fixes #3222

…cols

when inserting into a partitioned iceberg table, the select query now
includes an order by on the partition columns so iceberg can close
partition writers sequentially instead of keeping them all open at once.
this prevents the ICEBERG_TOO_MANY_OPEN_PARTITIONS error that happens
with many distinct partition combinations.
@kukushking

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
  • Commit ID: a320eca
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@kukushking

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: GitHubCodeBuild8756EF16-4rfo0GHQ0u9a
  • Commit ID: a320eca
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@kukushking

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: GitHubDistributedCodeBuild6-jWcl5DLmvupS
  • Commit ID: 291a646
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@kukushking

Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: GitHubCodeBuild8756EF16-4rfo0GHQ0u9a
  • Commit ID: 291a646
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@knQzx knQzx changed the title fix iceberg too many open partitions by sorting inserts fix(iceberg): too many open partitions by sorting inserts Apr 7, 2026
@knQzx

knQzx commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

all checks are passing, ready for review when you get a chance

@kukushking kukushking left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, looks great. I've spotted that identifier sanitization is missing in the module but that's a separate issue.

@kukushking
kukushking merged commit 2ec7087 into aws:main Apr 7, 2026
28 of 29 checks 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.

ICEBERG_TOO_MANY_OPEN_PARTITIONS awswrangler.athena.to_iceberg

2 participants