In Snowflake, is there an easier way to select multiple rows of fake data in memory without loading actual data into a table? Below is a sample query showing how I currently generate an object containing multiple rows of fake data.
with
fake_row_1 as (
select
1 as num,
'one' as txt
),
fake_row_2 as (
select
2 as num,
'two' as txt
),
fake_row_3 as (
select
3 as num,
'three' as txt
),
fake_table as (
select * from fake_row_1 union
select * from fake_row_2 union
select * from fake_row_3
)
select *
from fake_table
I am trying to test changes to query logic, and instead of loading and unloading test data into a test table, I am trying to stage a fake table in memory to more quickly validate expected results.
Ideally, I would be able to run a query similar to the following.
with
fake_table as (
select
columns (num, txt)
values (1, 'one'),
(2, 'two'),
(3, 'three')
)
select *
from fake_table
Could you do the union in the CTE?
with
fake_rows as (
select
1 as num,
'one' as txt
union
select
2,
'two'
union
select
3,
'three'
)
select *
from fake_rows
This might be a little cleaner:
with
fake_rows as (
select $1 AS txt,
$2 as num
FROM
(VALUES
(1,'one'),
(2,'two'),
(3,'three')
))
select * from fake_rows