There is a lot of documentation on gcp about querying sharded/wildcard tables [1][2], but I can't seem to figure out how to create or insert data into such as table.
Here's a trivial and mostly nonsensical example:
-- STANDARD SQL
CREATE TABLE IF NOT EXISTS `mydataset.mytable_CA` AS
SELECT "CA" as COUNTRY_CODE
CREATE TABLE IF NOT EXISTS `mydataset.mytable_US` AS
SELECT "US" as COUNTRY_CODE
SELECT * FROM `mydataset.mytable_*` WHERE _TABLE_SUFFIX = "CA"
Wildcards in CREATE-staments
How do I use wildcards in the create statement?
-- STANDARD SQL
-- DOES NOT WORK
CREATE TABLE IF NOT EXISTS `mydataset.mytable_*` AS
SELECT "US" as COUNTRY_CODE WHERE _TABLE_SUFFIX = "US"
Wildcards in INSERT-statements
Similarly, how do I do inserts?
Is it possible to do something along the lines of the following:
-- STANDARD SQL
-- DOES NOT WORK
INSERT INTO `mydataset.mytable_*` WHERE _TABLE_SUFFIX = COUNTRY_CODE
SELECT * FROM UNNEST(["US", "US", "CA"]) as COUNTRY_CODE
I know it is recommended to use partitioning and clustering, but I am asking specifically about wildcards, so please indulge me :)
Is this possible using standard SQL? If not, how about legacy SQL?