I am trying to write a BigQuery script that I can store as a procedure, I would like one of the arguments I pass to be used in the table name that is written out by the scri
So far we have officially announced BigQuery scripting document, which is still in Beta phase, leveraging usage of dynamic parameters (variables) as a placeholders for values in SQL queries . However, according to Parameterized queries in BigQuery documentation, query parameters can't be used for SQL object identifiers:
Parameters cannot be used as substitutes for identifiers, column names, table names, or other parts of the query.
Why not just use Execute Immediate with concat
if you know the table schema?
EXECUTE IMMEDIATE CONCAT('CREATE TABLE `', id, '` (column_name STRING)');
Maybe you can use a wildcard table. You would create a wildcard table with all subtables you want to query and use the WHERE
clause to select any subtable you want. Just be careful, the tables must have the same schema.