You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "akoshchiy (via GitHub)" <gi...@apache.org> on 2025/02/03 21:11:12 UTC

[I] ORDER BY with compound expr is not working [datafusion]

akoshchiy opened a new issue, #14459:
URL: https://github.com/apache/datafusion/issues/14459

   ### 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_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] ORDER BY with compound expr is not working [datafusion]

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead closed issue #14459: ORDER BY with compound expr is not working
URL: https://github.com/apache/datafusion/issues/14459


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] ORDER BY with compound expr is not working [datafusion]

Posted by "akoshchiy (via GitHub)" <gi...@apache.org>.
akoshchiy commented on issue #14459:
URL: https://github.com/apache/datafusion/issues/14459#issuecomment-2632085363

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org