{"action":"created","issue":{"url":"https://api.github.com/repos/slamdata/slamengine/issues/597","labels_url":"https://api.github.com/repos/slamdata/slamengine/issues/597/labels{/name}","comments_url":"https://api.github.com/repos/slamdata/slamengine/issues/597/comments","events_url":"https://api.github.com/repos/slamdata/slamengine/issues/597/events","html_url":"https://github.com/slamdata/slamengine/issues/597","id":56592601,"number":597,"title":"Error when ORDER BY references raw field name when SELECT aliases the field, and field is in GROUP BY and additional fields are returned in the SELECT results","user":{"login":"pjaffe","id":5993153,"avatar_url":"https://avatars.githubusercontent.com/u/5993153?v=3","gravatar_id":"","url":"https://api.github.com/users/pjaffe","html_url":"https://github.com/pjaffe","followers_url":"https://api.github.com/users/pjaffe/followers","following_url":"https://api.github.com/users/pjaffe/following{/other_user}","gists_url":"https://api.github.com/users/pjaffe/gists{/gist_id}","starred_url":"https://api.github.com/users/pjaffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjaffe/subscriptions","organizations_url":"https://api.github.com/users/pjaffe/orgs","repos_url":"https://api.github.com/users/pjaffe/repos","events_url":"https://api.github.com/users/pjaffe/events{/privacy}","received_events_url":"https://api.github.com/users/pjaffe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/slamdata/slamengine/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/slamdata/slamengine/labels/ready","name":"ready","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/slamdata/slamengine/milestones/6","labels_url":"https://api.github.com/repos/slamdata/slamengine/milestones/6/labels","id":839374,"number":6,"title":"1.3","description":"","creator":{"login":"jdegoes","id":156745,"avatar_url":"https://avatars.githubusercontent.com/u/156745?v=3","gravatar_id":"","url":"https://api.github.com/users/jdegoes","html_url":"https://github.com/jdegoes","followers_url":"https://api.github.com/users/jdegoes/followers","following_url":"https://api.github.com/users/jdegoes/following{/other_user}","gists_url":"https://api.github.com/users/jdegoes/gists{/gist_id}","starred_url":"https://api.github.com/users/jdegoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdegoes/subscriptions","organizations_url":"https://api.github.com/users/jdegoes/orgs","repos_url":"https://api.github.com/users/jdegoes/repos","events_url":"https://api.github.com/users/jdegoes/events{/privacy}","received_events_url":"https://api.github.com/users/jdegoes/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":9,"state":"open","created_at":"2014-10-24T18:33:05Z","updated_at":"2015-02-04T21:53:22Z","due_on":"2015-03-02T07:00:00Z","closed_at":null},"comments":3,"created_at":"2015-02-04T21:47:12Z","updated_at":"2015-02-05T00:25:27Z","closed_at":null,"body":"This had worked against the admin jar released under SHA d9c9ac0 (SNAPHSHOT 861) and fails under SHA 4a9b703 (SNAPHSHOT 869).  There is an easy workaround of changing the ORDER BY clause to reference the field Alias name, versus the raw field name.  However, I believe ANSI SQL allows for referencing the actual field names in the ORDER BY, and this appears to be a regression issue.\r\n```\r\nSELECT distinct category AS \"Result Alias\", COUNT(*)\r\n\tFROM \"/SimpleParent\"\r\n\tGROUP BY category\r\n\tORDER BY category\r\n```\r\nFails with:\r\n```\r\njava.lang.RuntimeException: cannot merge class slamdata.engine.physical.mongodb.Workflow$$Read with class slamdata.engine.physical.mongodb.Workflow$$Group\r\n```\r\nBut any of the following mitigate the error (the first two at least still provide access to the same result data):\r\n* Changing the ORDER BY to be ORDER BY \"Result Alias\"\r\n* Removing the AS \"Result Alias\" from the SELECT\r\n* Removing the ORDER BY clause\r\n* Removing the GROUP BY clause\r\n* Removing the COUNT(*) from the SELECT results"},"comment":{"url":"https://api.github.com/repos/slamdata/slamengine/issues/comments/72970607","html_url":"https://github.com/slamdata/slamengine/issues/597#issuecomment-72970607","issue_url":"https://api.github.com/repos/slamdata/slamengine/issues/597","id":72970607,"user":{"login":"sellout","id":33031,"avatar_url":"https://avatars.githubusercontent.com/u/33031?v=3","gravatar_id":"","url":"https://api.github.com/users/sellout","html_url":"https://github.com/sellout","followers_url":"https://api.github.com/users/sellout/followers","following_url":"https://api.github.com/users/sellout/following{/other_user}","gists_url":"https://api.github.com/users/sellout/gists{/gist_id}","starred_url":"https://api.github.com/users/sellout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellout/subscriptions","organizations_url":"https://api.github.com/users/sellout/orgs","repos_url":"https://api.github.com/users/sellout/repos","events_url":"https://api.github.com/users/sellout/events{/privacy}","received_events_url":"https://api.github.com/users/sellout/received_events","type":"User","site_admin":false},"created_at":"2015-02-05T00:25:27Z","updated_at":"2015-02-05T00:25:27Z","body":"Translating to our test data again …\r\n```sql\r\nSELECT distinct sha AS \"Result Alias\", COUNT(*)\r\n    FROM \"/SimpleParent\"\r\n    GROUP BY sha\r\n    ORDER BY sha\r\n```"}}