Skip to content
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

SNOW-950840 Parse new result metadata attributes for internal use #1806

Merged

Conversation

sfc-gh-rpanchapakesan
Copy link
Contributor

@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan commented Nov 15, 2023

I added the NO-CHANGELOG-UPDATES label since this change does not affect the public API of the connector. Let me know if I should instead update the changelog.

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-950840

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

Created a new version of result metadata that contains new fields that have been added to the response (and are needed to support vector types in Snowpark). To avoid causing a breaking API change, this PR does not modify the existing ResultMetadata class (which is a named tuple so field additions could cause user-facing breakages). Instead, this change only adds parsing for a new ResultMetadataV2 class that internally replaces usages of ResultMetadata. The new metadata representation is only accessible via an internal attribute (for use by Snowpark).

Longer-term, the old class should be deprecated, but, until that point, this serves as a stop-gap to unblock other work.

@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan force-pushed the rpanchapakesan/SNOW-950840-parse-new-result-metadata branch from 7d91f84 to add7a7d Compare November 17, 2023 22:55
@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan added the NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md label Nov 17, 2023
@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan changed the title SNOW-950840 Parse new result metadata attributes SNOW-950840 Parse new result metadata attributes for internal use Nov 17, 2023
Copy link

@sfc-gh-mloring sfc-gh-mloring left a comment

Choose a reason for hiding this comment

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

Looks good on the vector side!

src/snowflake/connector/cursor.py Outdated Show resolved Hide resolved
@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan force-pushed the rpanchapakesan/SNOW-950840-parse-new-result-metadata branch from deb0dad to 26729b7 Compare November 20, 2023 20:24
@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan force-pushed the rpanchapakesan/SNOW-950840-parse-new-result-metadata branch from ef5dc65 to 3b7a22d Compare November 27, 2023 16:52
Comment on lines +239 to +243
is_nullable: bool,
display_size: int | None = None,
internal_size: int | None = None,
precision: int | None = None,
scale: int | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any particular reason why is_nullable moved up in order here compared to ResultMetadata. Does the ordering even matter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ordering does not matter. changes look good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I moved it up only since it doesn't have a default value. ResultMetadataV2 isn't a named tuple, so it shouldn't have any other user-visible effect.

@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan merged commit eceed98 into main Nov 28, 2023
71 of 73 checks passed
@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan deleted the rpanchapakesan/SNOW-950840-parse-new-result-metadata branch November 28, 2023 02:09
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2023
def describe(self, *args: Any, **kwargs: Any) -> list[ResultMetadata]:
def describe(
self, *args: Any, **kwargs: Any
) -> list[ResultMetadata | ResultMetadataV2]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be just List[ResultMetadata]?

Copy link
Contributor Author

@sfc-gh-rpanchapakesan sfc-gh-rpanchapakesan Dec 13, 2023

Choose a reason for hiding this comment

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

Thanks for catching this: it should be just List[ResultMetadata] since describe only returns the old format. Same for _describe_internal(but for the new format) in your other comment.


def _describe_internal(
self, *args: Any, **kwargs: Any
) -> list[ResultMetadata | ResultMetadataV2]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this returning a mix of ResultMetadata and ResultMetadataV2?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants