You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2023/01/11 16:47:42 UTC

[GitHub] [arrow-datafusion] The-Mr-L opened a new issue, #4874: Sub Query bug

The-Mr-L opened a new issue, #4874:
URL: https://github.com/apache/arrow-datafusion/issues/4874

   hey first of thank you for sharing. It is appreciated
   
   **Describe the bug**
   Error: Plan("Projection references non-aggregate values: Expression users.id could not be resolved from available columns: MAX(users.id)")
   **To Reproduce**
   sql```
   select
       id
   from
       (
           select
               id,
               max(id) max_id
           from
               users
       )
   
   ```
   **Expected behavior**
   id and max_id
   
   


-- 
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@arrow.apache.org.apache.org

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


[GitHub] [arrow-datafusion] jackwener commented on issue #4874: Sub Query bug

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

   Looks like the problem has been solved
   
   


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] Jefffrey commented on issue #4874: Sub Query bug

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

   This seems to be a SQLite specific feature: https://sqlite.org/lang_select.html#bare_columns_in_an_aggregate_query
   
   Specifically:
   
   > Most other SQL database engines disallow bare columns. If you include a bare column in a query, other database engines will usually raise an error. The ability to include bare columns in a query is an SQLite-specific extension.
   
   Indeed when I try the same query (`select id, max(id) max_id from users`) on Postgres I get an error:
   
   > SQL Error [42803]: ERROR: column "users.id" must appear in the GROUP BY clause or be used in an aggregate function
   
   And I believe this project mainly uses Spark/Postgres as reference for implementation.


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] Jefffrey commented on issue #4874: Sub Query bug

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

   This seems to be working as intended, since the subquery is incorrect:
   
   ```sql
   select id, max(id) max_id from users
   ```
   
   If you specify a non-aggregate column in the project list then you also need a group by, like so:
   
   ```sql
   select id, max(id) max_id from users group by id
   ```
   
   Though I'm not sure what your query is intended to do.


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] The-Mr-L commented on issue #4874: Sub Query bug

Posted by "The-Mr-L (via GitHub)" <gi...@apache.org>.
The-Mr-L commented on issue #4874:
URL: https://github.com/apache/arrow-datafusion/issues/4874#issuecomment-1403485043

   thanks for the reply,  so yes the query is just a stupid reproduction example.  but I might  as you say be wrong here but the query I mentioned works in sqlite and will just return the same as you point out in your comment.  I mean why is the result the same from doing "select id, max(id) max_id from users" vs  "select id,  max_id from (select id, max(id) max_id from users)"
   
   do I really need to group by id for the max id of all  records ?  


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] jackwener closed issue #4874: Sub Query bug

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener closed issue #4874: Sub Query bug
URL: https://github.com/apache/arrow-datafusion/issues/4874


-- 
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@arrow.apache.org

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


[GitHub] [arrow-datafusion] The-Mr-L commented on issue #4874: Sub Query bug

Posted by "The-Mr-L (via GitHub)" <gi...@apache.org>.
The-Mr-L commented on issue #4874:
URL: https://github.com/apache/arrow-datafusion/issues/4874#issuecomment-1404960759

   well okay my bad then. Thanks  @Jefffrey  :)


-- 
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@arrow.apache.org

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