Repository navigation
Add IcebergWriteOperator to write files into Iceberg tables - #77900
Open
vanshtuli-lang wants to merge 2 commits into
Open
vanshtuli-lang wants to merge 2 commits into
vanshtuli-lang wants to merge 2 commits into
Conversation
The Iceberg provider can read and inspect tables but not write them, so Dags landing data in Iceberg re-implement the same task: catalog credentials, casting to the table schema, replacing one slice with a filtered overwrite, the empty-day case and commit-conflict retries. Making that one tested code path removes the copies and makes reruns safe by default, since an unfiltered overwrite is refused. Glue catalogs commonly authenticate through an assumed AWS role, so the hook can now take its credentials from an AWS connection. Co-Authored-By: Claude <noreply@anthropic.com>
The compatibility tests for Airflow 2.11 and 3.0 run with SQLAlchemy 1.4, which pyiceberg's SQL catalog does not support, and the new optional amazon and openlineage extras make Iceberg tests run when those providers change. Co-Authored-By: Claude <noreply@anthropic.com>
vanshtuli-lang
requested review from
amoghrajesh,
ashb,
bugraoz93,
choo121600,
ephraimbuddy,
gopidesupavan,
jason810496,
jedcunningham,
jscheffl,
potiuk and
vatsrahul1001
as code owners
December 1, 2026 16:43
Contributor
|
This pull request changes CI files. It changes files that CI uses:
They do not decide which CI jobs run or on which runners, so its workflow runs are not held for this. A maintainer reviewing the pull request will check the CI change together with the rest of it. This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Iceberg provider can read and inspect tables but cannot write them, so Dags that land data in Iceberg keep re-implementing the same
@task: build catalog credentials, cast rows to the table schema, replace one slice with a filteredoverwrite, handle the empty-day case, and retry commit conflicts. This PR adds that as one tested code path.IcebergWriteOperatorreads Parquet, CSV or newline-delimited JSON from anyObjectStoragePathfilesystem (URIs, globs or a list) and commits it to an Iceberg table with pyiceberg inside the worker, so no query engine is needed.append,overwrite(needsoverwrite_filter),dynamic_partition_overwrite,upsert.overwritegets no filter (or an always-true one) it refuses to run, so a missing template can never truncate the table.on_empty_source:delete_filtered(default; deletes the filtered slice, and does nothing when there is no filter),skip,fail.extra_columnsadds constant columns (templated). The data is then cast to the table schema, and a missing required column fails before any commit. CSV and JSON are parsed with the table's column types, because otherwise pyarrow turns strings like2026-11-30into timestamps.airflow.dag_id,run_id,task_idandtry_number. XCom gets only{rows_written, snapshot_id, table}.IcebergHookwrite_table()/delete_rows()/cast_to_schema()hold the write logic, so@taskcode can reuse it.CommitFailedExceptionis retried with exponential backoff after a table refresh.aws_conn_id: credentials (including assumed-role session tokens) and the region come from an AWS connection and are passed as pyicebergclient.*properties. This is behind a newamazonextra, so there is no hard dependency."type"in the connection extra (for exampleglue). This is now documented rather than adding a second key.Dependencies
pyiceberg>=0.11.0(was 0.8.0). 0.11.0 is the first release whoseupsertacceptssnapshot_properties.dynamic_partition_overwriteandupsertthemselves arrived in 0.9.0.pyarrowis now declared. pyiceberg leaves it optional, but writes need it, and so does the existingget_snapshots().amazonandopenlineage.Not included: table maintenance (compaction, expiry, schema evolution), streaming writes (v1 reads the source into one Arrow table, and the docs say so), and an
iceberg://asset URI. Those can be follow-ups if wanted.Testing
SqlCatalog(SQLite) with a local warehouse, set up through an Airflow connection, without mocking pyiceberg. They cover every write mode, filtered-overwrite and delete refusal, schema casting, commit-conflict retry, the empty-source branches, CSV/JSON typing, glob sources and OpenLineage. The AWS bridge is tested with an autospeccedAwsBaseHook.breeze testing providers-tests --test-type "Providers[apache.iceberg]"→ 91 passedprek run --stage pre-commit→ passedprek run --stage manual mypy-providers→ passedbreeze build-docs apache.iceberg→ passedexample_iceberg_write.pyhas not been run end to end. Locally, the system-test harness did not pick up a connection to a throwaway SQL catalog, so it still needs a run against a real catalog.uv.lockchanged, so CI's wider suites were left to CI.The commit carries a
Co-Authored-By: Claudetrailer because the contributor's organization requires it on all commits. AI use is also disclosed below.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 5.5) following the guidelines
🤖 Generated with Claude Code