Home > Software engineering >  Select Values in BigQuery?
Select Values in BigQuery?

Time:10-26

Is it possible to do something like the following in BigQuery to quickly generate sample input?

SELECT * FROM values ('david',10), ('tom',20)

Or does it only accept the verbose SELECT ... UNION ALL ... format:

select 'david' name, 10 age union all select 'tom', 20;

CodePudding user response:

Consider below as an option

SELECT * FROM UNNEST([
    STRUCT('david' as name,10 as age), 
    ('tom', 20),
    ('jon', 30)
  ])    

OR

SELECT * FROM UNNEST([STRUCT<name STRING, age INT64>
    ('david',10), ('tom', 20), ('jon', 30)
  ])          

both give you quick dummy data to play with

enter image description here

  • Related