-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL ORDER BY Fails on list[f64] #19758
Comments
I think the underlying issue is that Polars doesn't let you sort list columns as of yet: df = pl.DataFrame({"x": [[4, 3], [1, 2]]})
df.sort("x")
# InvalidOperationError: `sort_with` operation not supported for dtype `list[i64]` |
Yeah, looks like it's probably the same issue. I'm surprised because looking at it from the SQL viewpoint, doing an ORDER BY is completely ordinary. I'll just have to stick with duckdb until Polars SQL gets much more robust. |
Actually it looks like something a bit different - we shouldn't have lists of lists in the group result. If I omit the
|
FYI, if you write the query like this (with a single outer df.sql("""
SELECT
Direction,
AVG(
CASE WHEN Direction IN ('N', 'S') THEN Pcts_NS ELSE Pcts_EW END
) AS Avg_Pct
FROM self
GROUP BY Direction
ORDER BY Avg_Pct DESC
""")
# shape: (4, 2)
# ┌───────────┬───────────┐
# │ Direction ┆ Avg_Pct │
# │ --- ┆ --- │
# │ str ┆ f64 │
# ╞═══════════╪═══════════╡
# │ W ┆ 62.1 │
# │ N ┆ 60.566667 │
# │ E ┆ 58.666667 │
# │ S ┆ 55.7 │
# └───────────┴───────────┘ Digging deeper I can see this isn't a SQL issue, as I can replicate with the standard DataFrame interface → "to be continued..." |
Agreed. Looks like a different issue. I've fallen back to duckdb. Thanks for the interesting response. |
Checks
Reproducible example
Log output
Issue description
Here's how I interpret the error message. Apparently, ORDER BY is unable to sort list[f64]. I assume this is an oversight as I can't see any special difficulty in such a sort. duckdb works as expected.
Can errors such as 'sort with' be changed to the SQL counterpart 'ORDER BY operation not supported ...
The original issue, not yet reported, was that the original SQL query would hang (never return). I whittled down the original SQL to what's shown here. So there may be another issue, the hang issue, somewhere in the mix.
Expected behavior
Expecting a result of a sorted df.
Installed versions
The text was updated successfully, but these errors were encountered: