Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

feat: adds the SerDeInfo class and tests - #2108

Merged
chalmerlowe merged 2 commits into
mainfrom
feat-b358215039-adds-serdeinfo-class
Jan 10, 2025
Merged

feat: adds the SerDeInfo class and tests#2108
chalmerlowe merged 2 commits into
mainfrom
feat-b358215039-adds-serdeinfo-class

Conversation

@chalmerlowe

Copy link
Copy Markdown
Collaborator

This PR adds the SerDeInfo (serializer/deserializer info) class and the associated tests, plus minor tweaks to support both of those changes.

@chalmerlowe
chalmerlowe requested review from a team and agrawal-siddharthJanuary 9, 2025 18:51
@product-auto-labelproduct-auto-labelBot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery API. labels Jan 9, 2025
@chalmerlowechalmerlowe assigned tswast and Linchin and unassigned alvarowolfxJan 9, 2025
Comment threadgoogle/cloud/bigquery/schema.py Outdated
class SerDeInfo:
"""Serializer and deserializer information.
Args:
serializationLibrary (str): Required. Specifies a fully-qualified class

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.

Suggested change
serializationLibrary (str): Required. Specifiesafully-qualifiedclass
serialization_library (str): Required. Specifiesafully-qualifiedclass

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.

+1 to transforming to PEP-8 compliant snake_case

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

@tswasttswast 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.

Overall approach looks great. A couple nits.

Comment threadgoogle/cloud/bigquery/schema.py Outdated
from google.cloud.bigquery import _helpers
from google.cloud.bigquery import standard_sql
from google.cloud.bigquery._helpers import (
_isinstance_or_raise,

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.

Nit: Use _helpers._isinstance_or_raise in the code instead.

Use import statements for packages and modules only, not for individual types, classes, or functions.

https://google.github.io/styleguide/pyguide.html#22-imports

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

This is great feedback. I had not realized that.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

Comment on lines +566 to +567
"""Serializer and deserializer information.
Args:

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.

Might need a blank line here for the docs renderer to work?

Suggested change
"""Serializeranddeserializerinformation.
Args:
"""Serializeranddeserializerinformation.
Args:

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

Comment threadgoogle/cloud/bigquery/schema.py Outdated
class SerDeInfo:
"""Serializer and deserializer information.
Args:
serializationLibrary (str): Required. Specifies a fully-qualified class

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.

+1 to transforming to PEP-8 compliant snake_case

Comment threadtests/unit/test_schema.py Outdated
Comment on lines +23 to +26
from google.cloud.bigquery.schema import (
PolicyTagList,
SerDeInfo,
)

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.

@chalmerlowechalmerloweJan 9, 2025

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Hmm. I attempted to correct this for both PolicyTagList and SerDeInfo.
Unfortunately, there is something about how PolicyTagList is handled in our code that did not like the change and it produced several failing tests. I did not want to clutter this PR with unrelated changes, nor did I want to delay the issuance of this PR.

So I resolved this in the following way:

  • I corrected SerDeInfo and throughout the code we reference schema.SerDeInfo.
  • I left the PolicyTagList code exactly as it was found.

return answer


class SerDeInfo:

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.

Is this the name in the REST API? I'd prefer the full names rather than abbreviations, but I'm OK with this if it's to be consistent with the proto/REST API.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

SerDeInfo is the name in the proto/REST API definitions.


@property
def serialization_library(self) -> Any:
"""Required. Specifies a fully-qualified class name of the serialization

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.

nit: I think Required. should only apply to the init.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

As mentioned in chat, I prefer to leave this as is.


@property
def name(self) -> Any:
"""Optional. Name of the SerDe. The maximum length is 256 characters."""

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.

nit: similarly, we can remove Optional. here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

As mentioned in chat, I prefer to leave this as is.

Comment threadgoogle/cloud/bigquery/schema.py Outdated
self._properties["serializationLibrary"] = value

@property
def name(self) -> Any:

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.

Suggested change
defname(self) ->Any:
defname(self) ->Optional[str]:

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

Comment threadgoogle/cloud/bigquery/schema.py Outdated
self.parameters = parameters

@property
def serialization_library(self) -> Any:

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.

Suggested change
defserialization_library(self) ->Any:
defserialization_library(self) ->str:

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

Comment threadgoogle/cloud/bigquery/schema.py Outdated
self._properties["name"] = value

@property
def parameters(self) -> Any:

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.

Suggested change
defparameters(self) ->Any:
defparameters(self) ->Optional[dict[str, str]]:

For consistent type annotations.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Resolved.

Comment threadgoogle/cloud/bigquery/schema.py
return self._properties.get("parameters")

@parameters.setter
def parameters(self, value: Optional[dict[str, str]] = None):

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.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

See reply above from Python Docs about the concept of optional versus typing.Optional.

@Linchin
Linchin self-requested a review January 10, 2025 18:21
@chalmerlowe
chalmerlowe merged commit 62960f2 into mainJan 10, 2025
@chalmerlowe
chalmerlowe deleted the feat-b358215039-adds-serdeinfo-class branch January 10, 2025 18:22
@release-pleaserelease-pleaseBot mentioned this pull request Jan 10, 2025
chalmerlowe added a commit that referenced this pull request Jan 22, 2025
* feat: adds SerDeInfo class and tests
* cleans up type hints and some minor tweaks
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.size: mPull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@chalmerlowe@tswast@Linchin@alvarowolfx