Repository navigation
feat(encryption): [15/N] Reject writes to encrypted tables #4478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,9 @@ def __init__( | |
| branch: str | None = MAIN_BRANCH, | ||
| ) -> None: | ||
| super().__init__(transaction) | ||
| from pyiceberg.encryption.manager import _reject_encrypted_writes | ||
|
|
||
| _reject_encrypted_writes(transaction.table_metadata) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we check with table.transaction() as tx:
tx.remove_properties("encryption.key-id")
tx.append(df)Java rejects both removing and changing the key ID at commit time (RESTTableOperations.java#L255-L273). Should we port that check, either here or in a follow-up? Right now this check only runs when the producer is constructed, not again when |
||
| self.commit_uuid = commit_uuid or uuid.uuid4() | ||
| self._io = io | ||
| self._operation = operation | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2401,6 +2401,31 @@ def test_scan_encrypted_table(table_v3_encrypted: Table) -> None: | |||||
| assert table_v3_encrypted.scan().to_arrow().num_rows == 0 | ||||||
|
|
||||||
|
|
||||||
| def test_writes_to_encrypted_table_are_rejected(table_v3_encrypted: Table, tmp_path: Path) -> None: | ||||||
| import pyarrow as pa | ||||||
|
|
||||||
| from pyiceberg.expressions import AlwaysTrue | ||||||
|
Comment on lines
+2406
to
+2407
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Suggested change
|
||||||
|
|
||||||
| table_v3_encrypted.metadata = table_v3_encrypted.metadata.model_copy(update={"location": f"file://{tmp_path}"}) | ||||||
| df = pa.table({"x": [1, 2, 3]}, schema=pa.schema([pa.field("x", pa.int64(), nullable=False)])) | ||||||
|
|
||||||
| for write in [ | ||||||
| lambda: table_v3_encrypted.append(df), | ||||||
| lambda: table_v3_encrypted.overwrite(df), | ||||||
| lambda: table_v3_encrypted.delete(AlwaysTrue()), | ||||||
| ]: | ||||||
| with pytest.raises(NotImplementedError, match="Writing to encrypted tables is not yet supported"): | ||||||
| write() | ||||||
|
|
||||||
| assert list(tmp_path.iterdir()) == [] | ||||||
|
|
||||||
|
|
||||||
| def test_metadata_only_updates_to_encrypted_table_are_allowed(table_v3_encrypted: Table) -> None: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this one also passes on main, since |
||||||
| transaction = table_v3_encrypted.transaction().set_properties(owner="me") | ||||||
|
|
||||||
| assert transaction.table_metadata.properties["owner"] == "me" | ||||||
|
|
||||||
|
|
||||||
| def test_inspect_encrypted_table(table_v3_encrypted: Table) -> None: | ||||||
| assert table_v3_encrypted.inspect.manifests().num_rows == 0 | ||||||
| assert table_v3_encrypted.inspect.all_manifests().num_rows == 0 | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this spot makes the most sense to block this, everything in the library goes through here today and hopefully we won't have to block this for long!