{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/7438","repository_url":"https://api.github.com/repos/influxdata/influxdb","labels_url":"https://api.github.com/repos/influxdata/influxdb/issues/7438/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/7438/comments","events_url":"https://api.github.com/repos/influxdata/influxdb/issues/7438/events","html_url":"https://github.com/influxdata/influxdb/issues/7438","id":181970193,"number":7438,"title":"Allow more function nesting in InfluxQL","user":{"login":"Tomcat-Engineering","id":12047075,"avatar_url":"https://avatars.githubusercontent.com/u/12047075?v=3","gravatar_id":"","url":"https://api.github.com/users/Tomcat-Engineering","html_url":"https://github.com/Tomcat-Engineering","followers_url":"https://api.github.com/users/Tomcat-Engineering/followers","following_url":"https://api.github.com/users/Tomcat-Engineering/following{/other_user}","gists_url":"https://api.github.com/users/Tomcat-Engineering/gists{/gist_id}","starred_url":"https://api.github.com/users/Tomcat-Engineering/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tomcat-Engineering/subscriptions","organizations_url":"https://api.github.com/users/Tomcat-Engineering/orgs","repos_url":"https://api.github.com/users/Tomcat-Engineering/repos","events_url":"https://api.github.com/users/Tomcat-Engineering/events{/privacy}","received_events_url":"https://api.github.com/users/Tomcat-Engineering/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/influxdata/influxdb/labels/area/queries","name":"area/queries","color":"fbca04"},{"url":"https://api.github.com/repos/influxdata/influxdb/labels/kind/feature%20request","name":"kind/feature request","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-10T09:24:52Z","updated_at":"2016-10-12T16:16:02Z","closed_at":null,"body":"### Feature Request\r\n\r\n__Proposal:__ Allow most functions in InfluxQL to be nested.  Simplify and document the rules about which combinations are valid.  \r\n\r\n__Current behavior:__ Not many functions allow nesting, so for example this query is forbidden even though it might be useful:\r\n\r\n\tSELECT last(elapsed(value)) FROM ...\r\n\r\nIt is also not clear from the documentation (or the code!) which combinations are allowed. For example, you are allowed to do this:\r\n\r\n\tSELECT derivative(mean(Alloc)) FROM runtime WHERE time > now() - 1d GROUP BY time(1h)\r\n\t\r\nbut not this:\r\n\r\n\tSELECT max(mean(Alloc)) FROM runtime WHERE time > now() - 1d GROUP BY time(1h)\r\n\r\nI wrote a new function but found it difficult to integrate with the query language because the nesting rules for each function seem to be individually hand-crafted - there was no way to say \"this is another aggregator, just apply the normal aggregator rules and let people use it wherever an aggregator is valid\".  \r\n\r\n__Desired behavior:__ You can nest any functions as deeply as you like, subject to a few rules based on the *function categories*.\r\n\r\nThe function categories are already defined in [the documentation](https://docs.influxdata.com/influxdb/v1.0/query_language/functions) but are not used much in the code.  They already effectively determine the behaviour in many situations (particularly group-by queries), although these rules are not currently explicit in either the code or the documentation.\r\n\r\n__Use case:__ There are many cases where nesting functions is useful.  Many of the [proposed future functions](#5930) are \"single-point operators\" like *sqrt* or *sin* and users will definitely expect to be allowed to nest these.\r\n\r\nSpecifying function composition rules in terms of categories rather than on a per-function basis will be a lot more scalable as more functions are added, and will make the behaviour easier to document."},"comment":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/comments/253261193","html_url":"https://github.com/influxdata/influxdb/issues/7438#issuecomment-253261193","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/7438","id":253261193,"user":{"login":"jsternberg","id":1212129,"avatar_url":"https://avatars.githubusercontent.com/u/1212129?v=3","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T16:16:02Z","updated_at":"2016-10-12T16:16:02Z","body":"I think this is likely going to be implemented by subqueries. I think we have an issue for that open somewhere, but I'll have to find it. For math functions (which we have none at the moment, but we do plan to add those at some point) like `pow()` and `sqrt`, those will be nestable and they will get treated the same as if they were normal variable references whenever we get around to that. I should make an issue to discuss the implementation of that."}}
{"actor":{"display_login":"jsternberg"}}