Created
September 10, 2024 20:51
-
-
Save judell/2a9b64a17a04238c828ccf827edc823e to your computer and use it in GitHub Desktop.
hn_unnest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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