{"action":"created","issue":{"url":"https://api.github.com/repos/influxdb/influxdb/issues/2568","labels_url":"https://api.github.com/repos/influxdb/influxdb/issues/2568/labels{/name}","comments_url":"https://api.github.com/repos/influxdb/influxdb/issues/2568/comments","events_url":"https://api.github.com/repos/influxdb/influxdb/issues/2568/events","html_url":"https://github.com/influxdb/influxdb/pull/2568","id":76137501,"number":2568,"title":"Wire up SELECT DISTINCT","user":{"login":"corylanou","id":585100,"avatar_url":"https://avatars.githubusercontent.com/u/585100?v=3","gravatar_id":"","url":"https://api.github.com/users/corylanou","html_url":"https://github.com/corylanou","followers_url":"https://api.github.com/users/corylanou/followers","following_url":"https://api.github.com/users/corylanou/following{/other_user}","gists_url":"https://api.github.com/users/corylanou/gists{/gist_id}","starred_url":"https://api.github.com/users/corylanou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corylanou/subscriptions","organizations_url":"https://api.github.com/users/corylanou/orgs","repos_url":"https://api.github.com/users/corylanou/repos","events_url":"https://api.github.com/users/corylanou/events{/privacy}","received_events_url":"https://api.github.com/users/corylanou/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/influxdb/influxdb/labels/2%20-%20Working","name":"2 - Working","color":"CCCCCC"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-13T21:59:50Z","updated_at":"2015-05-19T13:37:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/influxdb/influxdb/pulls/2568","html_url":"https://github.com/influxdb/influxdb/pull/2568","diff_url":"https://github.com/influxdb/influxdb/pull/2568.diff","patch_url":"https://github.com/influxdb/influxdb/pull/2568.patch"},"body":"## Distinct with strings\r\n\r\n### the raw data\r\n\r\n```sql\r\n> select * from names\r\nname: names\r\n-----------\r\ntime                    first   last\r\n2015-05-01T00:00:00Z    suzie   smith\r\n2015-05-01T08:00:00Z    frank   smith\r\n2015-05-01T16:00:00Z    jonny   jones\r\n```\r\n\r\n### distinct with no where or group by\r\n\r\n```sql\r\n> select distinct(first) from names\r\nname: names\r\n-----------\r\ntime                    distinct\r\n1970-01-01T00:00:00Z    [frank jonny suzie]\r\n\r\n> select distinct(last) from names\r\nname: names\r\n-----------\r\ntime                    distinct\r\n1970-01-01T00:00:00Z    [jones smith]\r\n```\r\n###  Distinct with no fields will currently return an error (not supported)\r\n\r\n```sql\r\n> select distinct() from names\r\nERR: error parsing query: distinct function requires at least one argument\r\n```\r\n\r\n###  Distinct with more than one field will currently return an error (not supported)\r\n\r\n```sql\r\n> select distinct(first, last) from names\r\nERR: error parsing query: distinct function can only have one argument\r\n```\r\n\r\n### Distinct with a group by and no where clause will err out (like all aggregate functions should)\r\n\r\n```sql\r\n> select distinct(last) from names group by time(1h)\r\nERR: error parsing query: aggregate functions with GROUP BY time require a WHERE time clause\r\n```\r\n\r\n### Distinct with group by and where should bucket values appropriatly\r\n\r\n```sql\r\n> select distinct(last) from names where time >= '2015-05-01T00:00:00Z' and time <= '2015-05-01T16:00:00Z' group by time(12h)\r\nname: names\r\n-----------\r\ntime                    distinct\r\n2015-05-01T00:00:00Z    [smith]\r\n2015-05-01T12:00:00Z    [jones]\r\n\r\n> select distinct(first) from names where time >= '2015-05-01T00:00:00Z' and time <= '2015-05-01T16:00:00Z' group by time(12h)\r\nname: names\r\n-----------\r\ntime                    distinct\r\n2015-05-01T00:00:00Z    [frank suzie]\r\n2015-05-01T12:00:00Z    [jonny]\r\n```\r\n\r\n## Distinct with numeric data\r\n\r\n### the raw data\r\n\r\n```sql\r\n> select * from cpu\r\nname: cpu\r\n---------\r\ntime                    value\r\n2015-05-01T00:00:00Z    1.1\r\n2015-05-01T08:00:00Z    1.2\r\n2015-05-01T16:00:00Z    1.3\r\n2015-05-02T00:00:00Z    2.1\r\n2015-05-02T08:00:00Z    2.2\r\n2015-05-02T16:00:00Z    2.3\r\n2015-05-03T00:00:00Z    3.1\r\n2015-05-03T08:00:00Z    3.2\r\n2015-05-03T16:00:00Z    3.3\r\n2015-05-04T00:00:00Z    4.1\r\n2015-05-04T08:00:00Z    4.2\r\n2015-05-04T16:00:00Z    4.3\r\n```\r\n\r\n### distinct with no where or group by\r\n\r\n```sql\r\nselect distinct(value) from cpu\r\nname: cpu\r\n---------\r\ntime                    distinct\r\n1970-01-01T00:00:00Z    [1.1 1.2 1.3 2.1 2.2 2.3 3.1 3.2 3.3 4.1 4.2 4.3]\r\n```\r\n\r\n### distinct with different groupings\r\n\r\n```sql\r\n> select distinct(value) from cpu where time >= '2015-05-01T00:00:00Z' and time <= '2015-05-04T00:00:00Z' group by time(12h)\r\nname: cpu\r\n---------\r\ntime                    distinct\r\n2015-05-01T00:00:00Z    [1.1 1.2]\r\n2015-05-01T12:00:00Z    [1.3]\r\n2015-05-02T00:00:00Z    [2.1 2.2]\r\n2015-05-02T12:00:00Z    [2.3]\r\n2015-05-03T00:00:00Z    [3.1 3.2]\r\n2015-05-03T12:00:00Z    [3.3]\r\n2015-05-04T00:00:00Z    [4.1 4.2]\r\n```\r\n\r\n```sql\r\n> select distinct(value) from cpu where time >= '2015-05-01T00:00:00Z' and time <= '2015-05-04T00:00:00Z' group by time(1d)\r\nname: cpu\r\n---------\r\ntime                    distinct\r\n2015-05-01T00:00:00Z    [1.1 1.2 1.3]\r\n2015-05-02T00:00:00Z    [2.1 2.2 2.3]\r\n2015-05-03T00:00:00Z    [3.1 3.2 3.3]\r\n2015-05-04T00:00:00Z    [4.1 4.2 4.3]\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/influxdb/influxdb/issues/comments/103496638","html_url":"https://github.com/influxdb/influxdb/pull/2568#issuecomment-103496638","issue_url":"https://api.github.com/repos/influxdb/influxdb/issues/2568","id":103496638,"user":{"login":"dgnorton","id":209347,"avatar_url":"https://avatars.githubusercontent.com/u/209347?v=3","gravatar_id":"","url":"https://api.github.com/users/dgnorton","html_url":"https://github.com/dgnorton","followers_url":"https://api.github.com/users/dgnorton/followers","following_url":"https://api.github.com/users/dgnorton/following{/other_user}","gists_url":"https://api.github.com/users/dgnorton/gists{/gist_id}","starred_url":"https://api.github.com/users/dgnorton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgnorton/subscriptions","organizations_url":"https://api.github.com/users/dgnorton/orgs","repos_url":"https://api.github.com/users/dgnorton/repos","events_url":"https://api.github.com/users/dgnorton/events{/privacy}","received_events_url":"https://api.github.com/users/dgnorton/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T13:37:03Z","updated_at":"2015-05-19T13:37:03Z","body":"Need to add more tests for the validation code.  e.g. `select count(distinct(too, many, arguments))` passes."}}