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

Add more BigQuery support. Fix up documentation. #60

Merged
merged 13 commits into from
Jul 22, 2024
Prev Previous commit
Next Next commit
add Table.__getattr__
troyraen committed Jul 22, 2024
commit bd0a94a01c1221d0d8a4e91a1698a065826d9e98
13 changes: 13 additions & 0 deletions pittgoogle/bigquery.py
Original file line number Diff line number Diff line change
@@ -204,6 +204,19 @@ def from_cloud(
_ = table.table
return table

def __getattr__(self, attr):
"""If ``attr`` doesn't exist in this class, try getting it from the underlying ``google.cloud.bigquery.Table``.

Raises:
AttributeError:
if ``attr`` doesn't exist in either the pittgoogle or google.cloud API.
"""
try:
return getattr(self.table, attr)
except AttributeError as excep:
msg = f"Neither 'pittgoogle.bigquery.Table' nor 'google.cloud.bigquery.Table' has attribute '{attr}'"
raise AttributeError(msg) from excep

@property
def auth(self) -> Auth:
"""Credentials for the Google Cloud project that owns this table.