feat(bigquery): add support for sheets ranges#9416
Conversation
| # Use a shareable link or grant viewing access to the email address you | ||
| # used to authenticate with BigQuery (this example Sheet is public). | ||
| sheet_url = ( | ||
| "https://docs.google.com/spreadsheets/" |
There was a problem hiding this comment.
Actually, let's continue using the previous sheet. https://docs.google.com/spreadsheets/d/1i_QCL-7HcSyUZmIbP9E6lO_T5u3HnpLe7dnpHaijg_E/edit?usp=sharing
I was thinking we'd want a different set of data for the range queries, but if we're still querying US States, we should just use the existing sheet.
| external_config.source_uris = [sheet_url] | ||
| external_config.options.skip_leading_rows = 1 # Optionally skip header row. | ||
| external_config.options.range = ( | ||
| "Sheet1!A10:B30" |
There was a problem hiding this comment.
Let's use a range that is more possible to verify the correct behavior. Since the original sheet is sorted alphabetically, the range A1:B48 should only get "Washington".
There was a problem hiding this comment.
I decided to use A20:B49 range. To show that it can be used not from the beginning of the sheet.
|
|
||
| # Wait for the query to complete. | ||
| w_states = list(query_job) | ||
| print("There are {} states with names starting with W.".format(len(w_states))) |
There was a problem hiding this comment.
Let's update the print statement to indicate that we used a range: ... starting with W in the selected range.
Closes: #9082
List of changes:
rangesnippetsquery_external_sheets_permanent_table+ testquery_external_sheets_temporary_table+ test