Skip to content

TEST: adopt new rest catalog image and enable tableExists tests - #1389

Merged
sungwy merged 4 commits into
apache:mainfrom
sungwy:iceberg-rest-fixture-image
Dec 7, 2024
Merged

TEST: adopt new rest catalog image and enable tableExists tests#1389
sungwy merged 4 commits into
apache:mainfrom
sungwy:iceberg-rest-fixture-image

Conversation

@sungwy

@sungwysungwy commented Nov 29, 2024

Copy link
Copy Markdown
Collaborator

NOTE: the test is failing because tableExists endpoint isn't exposed on the adapter. Related fix: apache/iceberg#11678

Comment threaddev/docker-compose-integration.yml Outdated
@Fokko

Fokko commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

The image is published, including the fix around the tableExists, so 🤞

@Fokko

Fokko commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Hmm, still an issue with the tableExists:

 @pytest.mark.integration
def test_table_v1_with_null_nested_namespace(session_catalog: Catalog, arrow_table_with_null: pa.Table) -> None:
identifier = "default.lower.table_v1_with_null_nested_namespace"
tbl = _create_table(session_catalog, identifier, {"format-version": "1"}, [arrow_table_with_null])
assert tbl.format_version == 1, f"Expected v1, got: v{tbl.format_version}"
assert session_catalog.load_table(identifier) is not None
> assert session_catalog.table_exists(identifier)
E AssertionError: assert False
E + where False = <bound method RestCatalog.table_exists of local (<class 'pyiceberg.catalog.rest.RestCatalog'>)>('default.lower.table_v1_with_null_nested_namespace')
E + where <bound method RestCatalog.table_exists of local (<class 'pyiceberg.catalog.rest.RestCatalog'>)> = local (<class 'pyiceberg.catalog.rest.RestCatalog'>).table_exists
tests/integration/test_writes/test_writes.py:1373: AssertionError
=============================== warnings summary ========================

@sungwy

Copy link
Copy Markdown
CollaboratorAuthor

:) @Fokko I'm on my way to the office, but will take a look at this in a few minutes

@sungwy
sungwy marked this pull request as ready for review December 4, 2024 13:48
@sungwy

Copy link
Copy Markdown
CollaboratorAuthor

@Fokko - it looks like the issue is because the rest-fixture is returning a 200 response. I've put in edits to allow PyIceberg to infer a 200 response as being successful.

The proposed solution deviates from the REST Catalog Spec, but this is already the behavior of PyIceberg when handles the success codes of the other endpoints that are also meant to return 204 response:

def_handle_non_200_response(self, exc: HTTPError, error_handler: Dict[int, Type[Exception]]) ->None:
exception: Type[Exception]
ifexc.responseisNone:
raiseValueError("Did not receive a response")
code=exc.response.status_code
ifcodeinerror_handler:
exception=error_handler[code]
elifcode==400:
exception=BadRequestError
elifcode==401:
exception=UnauthorizedError
elifcode==403:
exception=ForbiddenError
elifcode==422:
exception=RESTError
elifcode==419:
exception=AuthorizationExpiredError
elifcode==501:
exception=NotImplementedError
elifcode==503:
exception=ServiceUnavailableError
elif500<=code<600:
exception=ServerError
else:
exception=RESTError

@Fokko

Fokko commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Thanks for following this up @sungwy. I think it is okay to mark all 2xx responses as table exists. Polaris had a similar issue: #1363

@kevinjqliukevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

woot! LGTM

if response.status_code == 404:
return False
elif response.status_code == 204:
elif response.status_code in (200, 204):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we upstream this to the spec?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sungwy
sungwy merged commit 6714257 into apache:mainDec 7, 2024
@sungwy
sungwy deleted the iceberg-rest-fixture-image branch December 7, 2024 02:36
@sungwy

Copy link
Copy Markdown
CollaboratorAuthor

Thanks for the reviews @Fokko and @kevinjqliu !

@sungwysungwy mentioned this pull request Dec 7, 2024
2 tasks
sungwy added a commit to sungwy/iceberg-python that referenced this pull request Dec 7, 2024
…he#1389)
* test new rest catalog image
* Point to `iceberg-rest-fixture`
* allow 200 response in table_exists
* be graceful in handling 200 response in table_exists
---------
Co-authored-by: Fokko Driesprong <fokko@apache.org>
sungwy added a commit to sungwy/iceberg-python that referenced this pull request Dec 7, 2024
…he#1389)
* test new rest catalog image
* Point to `iceberg-rest-fixture`
* allow 200 response in table_exists
* be graceful in handling 200 response in table_exists
---------
Co-authored-by: Fokko Driesprong <fokko@apache.org>
sungwy added a commit to sungwy/iceberg-python that referenced this pull request Dec 24, 2024
…he#1389)
* test new rest catalog image
* Point to `iceberg-rest-fixture`
* allow 200 response in table_exists
* be graceful in handling 200 response in table_exists
---------
Co-authored-by: Fokko Driesprong <fokko@apache.org>
Sign up for freeto 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.

3 participants

@sungwy@Fokko@kevinjqliu