Using .js
files to generate queries from a template
#1616
Replies: 1 comment 3 replies
-
Ah, so I think you are trying to do something at compile-time which you can only actually do at run-time. Dataform code is "compiled" (really: "executed") to produce static SQL, i.e. all JavaScript is gone. Compilation is (by design) hermetic, i.e. your JavaScript cannot communicate with the outside world - including BigQuery. Later, the compiled SQL is then executed against BigQuery. I think you want to use BigQuery scripting (https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language) for this. You'd have (probably) an Unfortunately I cannot see a way of making those run in parallel. |
Beta Was this translation helpful? Give feedback.
-
I couldn't Google an obvious answer to this, but there probably is one. Apologies if so.
I want to generate a large number of bulk-load BQ Federation queries to run in parallel in a
.js
file.I pull the CloudSQL info schema into a BQ dataform table like so:
ods_info_schema.sqlx
Now, I want to use the entire contents of that table as the array for a
forEach
in the following file:federation.js
My guess is that I probably need to use a JS library to pull in the table contents as an array, but I was hoping for a native way to do it in Dataform.
Thanks for any help you can provide!
Beta Was this translation helpful? Give feedback.
All reactions