Skip to content

Commit f16a8e4

Browse files
committed
feat: add support for setting and removing table properties on console
1 parent ca70442 commit f16a8e4

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pyiceberg/cli/console.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ def table(ctx: Context, identifier: str, property_name: str, property_value: str
361361
catalog, output = _catalog_and_output(ctx)
362362
identifier_tuple = Catalog.identifier_to_tuple(identifier)
363363

364-
_ = catalog.load_table(identifier_tuple)
365-
output.text(f"Setting {property_name}={property_value} on {identifier}")
366-
raise NotImplementedError("Writing is WIP")
364+
table = catalog.load_table(identifier_tuple)
365+
table.transaction().set_properties({property_name: property_value}).commit_transaction()
366+
output.text(f"Set {property_name}={property_value} on {identifier}")
367367

368368

369369
@properties.group()
@@ -398,8 +398,8 @@ def table(ctx: Context, identifier: str, property_name: str) -> None: # noqa: F
398398
catalog, output = _catalog_and_output(ctx)
399399
table = catalog.load_table(identifier)
400400
if property_name in table.metadata.properties:
401-
output.exception(NotImplementedError("Writing is WIP"))
402-
ctx.exit(1)
401+
table.transaction().remove_properties(property_name).commit_transaction()
402+
output.text(f"Property {property_name} removed from {identifier}")
403403
else:
404404
raise NoSuchPropertyException(f"Property {property_name} does not exist on {identifier}")
405405

tests/cli/test_console.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ def test_properties_set_table(catalog: InMemoryCatalog) -> None:
476476

477477
runner = CliRunner()
478478
result = runner.invoke(run, ["properties", "set", "table", "default.my_table", "location", "s3://new_location"])
479-
assert result.exit_code == 1
480-
assert "Writing is WIP" in result.output
479+
assert result.exit_code == 0
480+
assert result.output == "Set location=s3://new_location on default.my_table\n"
481481

482482

483483
def test_properties_set_table_does_not_exist(catalog: InMemoryCatalog) -> None:
@@ -518,8 +518,8 @@ def test_properties_remove_table(catalog: InMemoryCatalog) -> None:
518518

519519
runner = CliRunner()
520520
result = runner.invoke(run, ["properties", "remove", "table", "default.my_table", "read.split.target.size"])
521-
assert result.exit_code == 1
522-
assert "Writing is WIP" in result.output
521+
assert result.exit_code == 0
522+
assert result.output == "Property read.split.target.size removed from default.my_table\n"
523523

524524

525525
def test_properties_remove_table_property_does_not_exists(catalog: InMemoryCatalog) -> None:
@@ -894,8 +894,8 @@ def test_json_properties_set_table(catalog: InMemoryCatalog) -> None:
894894
result = runner.invoke(
895895
run, ["--output=json", "properties", "set", "table", "default.my_table", "location", "s3://new_location"]
896896
)
897-
assert result.exit_code == 1
898-
assert "Writing is WIP" in result.output
897+
assert result.exit_code == 0
898+
assert result.output == """"Set location=s3://new_location on default.my_table"\n"""
899899

900900

901901
def test_json_properties_set_table_does_not_exist(catalog: InMemoryCatalog) -> None:
@@ -938,8 +938,8 @@ def test_json_properties_remove_table(catalog: InMemoryCatalog) -> None:
938938

939939
runner = CliRunner()
940940
result = runner.invoke(run, ["--output=json", "properties", "remove", "table", "default.my_table", "read.split.target.size"])
941-
assert result.exit_code == 1
942-
assert "Writing is WIP" in result.output
941+
assert result.exit_code == 0
942+
assert result.output == """"Property read.split.target.size removed from default.my_table"\n"""
943943

944944

945945
def test_json_properties_remove_table_property_does_not_exists(catalog: InMemoryCatalog) -> None:

0 commit comments

Comments
 (0)