-
Notifications
You must be signed in to change notification settings - Fork 180
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
Handle records and arrays #145
Comments
I think it should return a data frame with list columns in that scenario. Could you provide a minimal reprex of such data? |
Here is an example query:
Rather than having to flatten repeated fields (ARRAYS), I would like to capture the JSON output and load it into a structured list in R. |
Thanks, that's useful. I think it should be trivial to return this data as a list-column. |
Even with the query explorer, and this simpler query: SELECT repository
FROM [bigquery-public-data.samples.github_nested]
WHERE repository.owner IN ('hadley') LIMIT 100 I had to check "allow large results" and uncheck "flatten" results. Do you have an example of this working elsewhere? (I just want to double check that it is really this hard; I thought it would be easier) |
Yes. This this the only way I know to get nested JSON results from BigQuery Web UI. |
You can also use the UI -- use standard SQL, and click the button to view results as JSON. The |
Reprex with latest (in-dev) API: tb <- bq_project_query(bq_test_project(),
"SELECT * FROM publicdata.samples.github_nested WHERE repository.owner IN ('hadley') LIMIT 100",
use_legacy_sql = FALSE
)
df <- bq_table_download(tb) It's a bit harder than I had ancticipated thanks to the extreme nesting of the json. |
Focussing the query a little to get a smaller selection repeated and non-repeated records.
|
Here is another example:
vs what it look like from the UI
Doing the same query the way @hadley did trigger an error:
|
Thanks @zippeurfou here's an even more minimal example for testing: tb1 <- bq_project_query(bq_test_project(), "SELECT STRUCT(1 AS a, 'abc' AS b) as x")
bq_table_download(tb1)
tb2 <- bq_project_query(bq_test_project(), "SELECT GENERATE_ARRAY(1, 10) as x")
bq_table_download(tb2) |
Parse JSON in C++: this considerably improves performance and adds full support for arrays, records, and arrays of records. Fixes #145
It seems that the schema generator doesn't support saving lists back to bigquery as a repeated field? Am I missing something or should I open a ticket? |
@bbhoss please file a new issue with simple reprex. |
Can
extract_data
be changed to support optionally returning structured JSON data instead of a data.frame? This is useful when the query results includes ARRAYs and STRUCTs.The text was updated successfully, but these errors were encountered: