在BigQuery DDL和外部GCS存储桶中使用变量

时间:2020-10-30 20:03:54

标签: google-bigquery google-cloud-storage

仅使用BigQuery数据定义语言和标准SQL,是否可以将当前日期用作变量,以将其用作以下查询中的-posts(Collection) | +---{userID} (Document) | +---userPosts (collection) | +---{Documents to be checked} (Document) | +-Url1(field) +-Url2(field) +-string1(field)<- check this field for swear +-string2(field)<- check this field for swear 路径?

gs://

1 个答案:

答案 0 :(得分:1)

EXECUTE IMMEDIATE format("""
  CREATE OR REPLACE EXTERNAL TABLE staging.my_table
  OPTIONS (
    format = 'NEWLINE_DELIMITED_JSON',
    uris = ['gs://bucket/path/to/%s/*.jsonl']
  )
""", CAST(CURRENT_DATE() AS STRING));

最佳做法是在GCS上使用Hive partitioning

相关问题