Skip to content

Commit

Permalink
Merge pull request #44 from gogovan/AN-5970
Browse files Browse the repository at this point in the history
added bigquery get table api
  • Loading branch information
ggx-jacechun authored Nov 17, 2023
2 parents 1877444 + d3a220a commit 43a88ea
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ggvlib/google/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ def query_to_storage_df(query: str) -> pd.DataFrame:
logger.debug(f"Running query: {query}")
storage_client = bigquery_storage.BigQueryReadClient()
result = (
_client()
.query(query)
.result()
.to_dataframe(bqstorage_client=storage_client)
_client().query(query).result().to_dataframe(bqstorage_client=storage_client)
)
logger.debug(f"Result: {len(result)} row(s)")
return result
Expand Down Expand Up @@ -137,3 +134,16 @@ def query_to_storage(
else:
raise ValueError("Invalid Big Query export format")
return query_job.result()


def get_table_info(project, dataset, table):

logger.debug(f"Getting table info: {table}")
# Make an API request to get the table resource.
try:
view = _client().get_table(f"{project}.{dataset}.{table}")
except Exception as e:
logger.info(f"Cannont get table info{e}")
view = None

return view

0 comments on commit 43a88ea

Please sign in to comment.