The `dagster-gcp` BigQueryResource class can be u...
# ask-community
e
The
dagster-gcp
BigQueryResource class can be used in the following way:
Copy code
@asset
def my_table(bigquery: BigQueryResource):
    with bigquery.get_client() as client:
        client.query("SELECT * FROM my_dataset.my_table")
is there a graceful way to enter and exit the context without using the
with
statement?
j
hey @Eric Loreaux - not really, the
with
statement is needed for handling credential setup. is there a reason the
with
statement doesn’t work for you?
e
Thanks, it's only a bit clunky in certain contexts - e.g. if you have a big chunk of conditional statements and only a few of those blocks require the client, then you have to indent the entire chunk. Not a huge issue
I guess I could also just use
with
separately on each of the blocks that require it
j
ok! just wanted to make sure it wasn’t causing functionality issues for some reason. i’ve been playing with a way to do authentication differently and that would remove the need for the with block, but it’s a side project and pretty low priority for me right now
👍 1