Using unnest in sqlp errors instead of returning results #3113
-
|
Describe the bug To Reproduce id,data
1,"a,b,c"
Run
`qsv sqlp data.csv "select id, unnest(string_to_array(data, ',')) as value from data"
**Expected behavior**
It returns 3 rows of data
```csv
id,value
1,a
1,b
1,cActual results Desktop (please complete the following information):
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
|
Thanks for the report @urkle . This appears to be a problem in Polars. There's an existing PR, but it has not been merged yet. |
Beta Was this translation helpful? Give feedback.
-
|
@urkle this should work: $ qsv sqlp data.csv "select first(id) as idf, unnest(string_to_array(data, ',')) as value from data"
idf,value
1,a
1,b
1,c |
Beta Was this translation helpful? Give feedback.
-
|
@jqnatividad that actually does not work, as it returns the very first ID only. id,data
1,"a,b,c"
2,
3,"b,c,d"$ qsv sqlp data.csv "select first(id) as id, unnest(string_to_array(data, ',')) as value from data"
id,value
1,a
1,b
1,c
1,
1,b
1,c
1,d
(7, 2) |
Beta Was this translation helpful? Give feedback.
-
|
Hope you don't mind @alexander-beedie that I'm looping you in... any suggestions? |
Beta Was this translation helpful? Give feedback.
-
|
@urkle What about using a Common Table Expression (CTE)? By first creating the array in a CTE then selecting from it, Polars SQL can maintain the row-by-row relationship... |
Beta Was this translation helpful? Give feedback.
-
|
Polars SQL support for inline |
Beta Was this translation helpful? Give feedback.
@urkle What about using a Common Table Expression (CTE)?
By first creating the array in a CTE then selecting from it, Polars SQL can maintain the row-by-row relationship...