Skip to content

Instantly share code, notes, and snippets.

@TobCap

TobCap/in.sql Secret

Created August 8, 2021 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TobCap/83d6d874f40e265b45cdb0c992317e00 to your computer and use it in GitHub Desktop.
Save TobCap/83d6d874f40e265b45cdb0c992317e00 to your computer and use it in GitHub Desktop.
another way of making temporary table by using UNNEST
-- refers to https://pod.hatenablog.com/entry/2021/08/04/111107
WITH points AS (
select * from UNNEST(ARRAY<STRUCT<id int, p STRUCT<x int64, y int64>>>[
(1, (0, 10)),
(2, (0, 10)),
(2, (0, 10))
])
)
SELECT * FROM points
[
{
"id": "1",
"p": {
"x": "0",
"y": "10"
}
},
{
"id": "2",
"p": {
"x": "0",
"y": "10"
}
},
{
"id": "2",
"p": {
"x": "0",
"y": "10"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment