Fokko commented on code in PR #405: URL: https://github.com/apache/iceberg-python/pull/405#discussion_r1485146614
########## tests/integration/test_reads.py: ########## @@ -467,3 +469,26 @@ def test_null_list_and_map(catalog: Catalog) -> None: # assert arrow_table["col_list_with_struct"].to_pylist() == [None, [{'test': 1}]] # Once https://github.com/apache/arrow/issues/38809 has been fixed assert arrow_table["col_list_with_struct"].to_pylist() == [[], [{'test': 1}]] + + +@pytest.mark.integration +def test_hive_locking(catalog_hive: HiveCatalog) -> None: + table = create_table(catalog_hive) + + database_name: str + table_name: str + _, database_name, table_name = table.identifier + + hive_client: _HiveClient = catalog_hive._client + blocking_lock_request: LockRequest = catalog_hive._create_lock_request(database_name, table_name) + + with hive_client as open_client: + # Force a lock on the test table + lock: LockResponse = open_client.lock(blocking_lock_request) + assert lock.state == LockState.ACQUIRED + + try: + with pytest.raises(CommitFailedException, match="Cannot acquire lock"): + table.transaction().set_properties(lock="fail").commit_transaction() + finally: + open_client.unlock(UnlockRequest(lock.lockid)) Review Comment: I think we need to create a separate HiveClient: ```suggestion hive_client: _HiveClient = _HiveClient(catalog_hive.properties["uri"]) blocking_lock_request: LockRequest = catalog_hive._create_lock_request(database_name, table_name) with hive_client as open_client: # Force a lock on the test table lock: LockResponse = open_client.lock(blocking_lock_request) assert lock.state == LockState.ACQUIRED try: with pytest.raises( CommitFailedException, match=re.escape("Failed to acquire lock for namespace=Namespace(root=['local', 'default']) name='t1', state: 2"), ): table.transaction().set_properties(lock="fail").commit_transaction() finally: open_client.unlock(UnlockRequest(lock.lockid)) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org