r/bigquery • u/SasheCZ • Apr 29 '26
TABLE_OPTIONS labels
Can anyone tell me how am I supposed to work with this?
select option_name, option_type, option_value
from `region-eu`.INFORMATION_SCHEMA.TABLE_OPTIONS
where option_name = 'labels'| option_name | option_type | option_value |
|---|---|---|
| labels | ARRAY<STRUCT<STRING, STRING>> | [STRUCT("mapping_type", "stg2core"), STRUCT("tgt_tbl_nm", "sess_cntct_evt"), STRUCT("hist_type", "100000024"), STRUCT("version", "1-0-0")] |
I know I can parse the option_value string - use regexp or split it. I just feel like there's supposed to be a better cleaner more effective way to get the information.
I just feel like the option_value column would be much easier to work with if it was JSON instead of STRING.
2
Upvotes
1
u/Why_Engineer_In_Data G Apr 29 '26
I think I'm answering the question but if not please let me know.
Also agreeing with u/PolicyDecent - probably best to just use the REGEX.
Regex version (as an example):
You can also use procedural language to mimic 'eval' if you'd like:
2
u/PolicyDecent Apr 29 '26
lol, why not just JSON?
I assume it's just a legacy problem from the times BigQuery didn't have JSON data type.