Reputation: 3172
How can i use the new UDF functionality to create "Dynamic SQL statement"? Is there a way to use UDF in order to construct SQL statement based on template and input variables, and later run this query?
Upvotes: 3
Views: 888
Reputation: 251
The documentation https://cloud.google.com/bigquery/user-defined-functions?hl=en says:
A UDF is similar to the "Map" function in a MapReduce: it takes a single row as input and produces zero or more rows as output. The output can potentially have a different schema than the input.
So your UDF receives just a single row. Therefore - no, UDF is not for the purpose you described in your question.
You might take a look at views - maybe that will suit you better: https://cloud.google.com/bigquery/querying-data#views
Upvotes: 2