-
I got a static data loader working with BigQuery:
This works fine loading static data, like
However, in the page I am trying to create, it needs to allow a viewer to pick a country from a dropdown. The dropdown works just fine when running, but I can't figure out how to do a dynamic query using my new
I've tried importing the
I understand the bundle errors here, but there has got to be a way to run a dynamic BigQuery query in a snippet, right? I am new to Observable overall, so there may be something obvious here. Is there anyway to use the built in Any help is appreciated, thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The module you are trying to import seems to work only with node.js, and there is no equivalent of "fs" for the browser. (I think this explains why Framework's attempts to massage the code with rollup fail.) Our model with data loaders is that you handle all of this in "data snapshots" that download the data once (authenticating properly) and then present it statically to the browser. You can still operate queries again this data snapshot, using sql, but the browser doesn't get to talk to bigquery directly. The recommendation (if there is a lot of data) is to save the snapshot in the efficient parquet format. If this still makes files too large, you can consider sharding the data into several static data loaders, for example one for each country or region (or, if you have a predominant region, one file for the large region and one file for the "rest of the world"). If you really must use "live bigquery", the official way to access BigQuery from the browser is through the http rest api—with a helper such as gapi to help with authentication (ref). But this implies that your users will have to authenticate against google—with implications in terms of security (and billing). An alternative is to have a proxy with your authentication credits, that mediates the queries between the browser and the database. But this is also "live code" that you need to host somewhere, maintain, and also has security implications. |
Beta Was this translation helpful? Give feedback.
The module you are trying to import seems to work only with node.js, and there is no equivalent of "fs" for the browser. (I think this explains why Framework's attempts to massage the code with rollup fail.)
Our model with data loaders is that you handle all of this in "data snapshots" that download the data once (authenticating properly) and then present it statically to the browser. You can still operate queries again this data snapshot, using sql, but the browser doesn't get to talk to bigquery directly.
The recommendation (if there is a lot of data) is to save the snapshot in the efficient parquet format. If this still makes files too large, you can consider sharding the data into sev…