Skip to content

Instantly share code, notes, and snippets.

@judell
Created September 10, 2024 20:51
Show Gist options
  • Save judell/2a9b64a17a04238c828ccf827edc823e to your computer and use it in GitHub Desktop.
Save judell/2a9b64a17a04238c828ccf827edc823e to your computer and use it in GitHub Desktop.
hn_unnest
# duckdb
with names as (
select
unnest(string_to_array(?, ',')) as name
),
# sqlite
WITH RECURSIVE names(name, remaining) AS (
SELECT
'',
? || ','
UNION ALL
SELECT
substr(remaining, 1, instr(remaining, ',') - 1),
substr(remaining, instr(remaining, ',') + 1)
FROM
names
WHERE
remaining != ''
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment