简体   繁体   中英

Bigquery : get the name of the table as column value

I have a dataset that contains several tables that have suffixes in their name:

  • table_src1_serie1
  • table_src1_serie2
  • table_src2_opt1
  • table_src2_opt2
  • table_src3_type1_v1
  • table_src3_type2_v1
  • table_src3_type2_v2

I know that i can use this type of queries in BQ:

select * from `project.dataset.table_*`

to get all the rows from theses different tables.

What i am trying to achieve is to have a column that will contain for instance the type of source (src1, src2, src3)

假设所有表的架构都相同-您可以在下方的选择列表中添加(适用于BigQuery Standard SQL)

SPLIT(_TABLE_SUFFIX, '_')[SAFE_OFFSET(0)] AS src 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM