Skip to content
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

ORDER BY with compound expr is not working #14459

Closed
akoshchiy opened this issue Feb 3, 2025 · 1 comment · Fixed by #14486
Closed

ORDER BY with compound expr is not working #14459

akoshchiy opened this issue Feb 3, 2025 · 1 comment · Fixed by #14486
Assignees
Labels
bug Something isn't working

Comments

@akoshchiy
Copy link
Contributor

Describe the bug

Query with compound sort expr (e.g. sum(a) + sum(b)) is failing.

To Reproduce

Run the script in datafusion-cli

CREATE TABLE t1(id INT, type VARCHAR, revenue INT);
INSERT INTO t1 VALUES (1, 'a', 199), (2, 'b', 238), (3, 'a', 301);

SELECT
        type,
        sum(revenue) + sum(revenue)
FROM t1
GROUP BY type
ORDER BY sum(revenue) + sum(revenue);

The output will be

type_coercion
caused by
Schema error: No field named t1.revenue. Valid fields are t1.type, "sum(t1.revenue) + sum(t1.revenue)".

Expected behavior

+------+----------------------------------+
| type | sum(t1.revenue)  + sum(t1.revenue) |
+------+----------------------------------+
| b    | 476                              |
| a    | 1000                            |
+------+----------------------------------+

Additional context

No response

@akoshchiy akoshchiy added the bug Something isn't working label Feb 3, 2025
@akoshchiy
Copy link
Contributor Author

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant