OUMOUSS_ELMEHDI
OUMOUSS_ELMEHDI

Reputation: 519

Bigquery : get the name of the table as column value

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

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)

Upvotes: 0

Views: 138

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173190

Assuming the schema of all tables the same - you can add below to your select list (for BigQuery Standard SQL)

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

Upvotes: 3

Related Questions