I am learning bigquery with python notebook, and I found out the very first lines of code as follows:
from google.cloud import bigquery
client = bigquery.Client()
hn_dataset_ref = client.dataset('hacker_news', project='bigquery-public-data')
hn_dset = client.get_dataset(hn_dataset_ref)
My question is why do we need to construct a dataset reference?
Can we do in a shorter way like below?
from google.cloud import bigquery
client = bigquery.Client()
hn_dset = client.get_dataset('bigquery-public-data.hacker_news')`
Yes, you can do it in the shorter way. When you use a string, the method will actually create a DatasetReference.
The long method was the old way to do it, and it is actually deprecated, so it is no longer recommended its use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With