BigQuery - Quickly mock a table

BigQuery - Quickly mock a table

Sometimes to test queries, you might want to quickly mock tables like table_inplace. Here’s one way to do it.

WITH table_inplace AS (
  SELECT * FROM UNNEST([ STRUCT
    (1 AS num, 'Sun' AS name),
    (2, 'Moon'),
    (3, 'Mars'),
    (4,'Earth')
    ]
  )
)

SELECT * FROM table_inplace

11. Nov 2022