Create table using a variable name in the BigQuery UI

前端 未结 3 1897
粉色の甜心
粉色の甜心 2020-12-07 04:37

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

相关标签:
3条回答
  • 2020-12-07 05:13

    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.

    0 讨论(0)
  • 2020-12-07 05:13

    Why not just use Execute Immediate with concat if you know the table schema?

    EXECUTE IMMEDIATE CONCAT('CREATE TABLE `', id, '` (column_name STRING)');
    
    0 讨论(0)
  • 2020-12-07 05:24

    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.

    0 讨论(0)
提交回复
热议问题