{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/9087","repository_url":"https://api.github.com/repos/influxdata/influxdb","labels_url":"https://api.github.com/repos/influxdata/influxdb/issues/9087/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/9087/comments","events_url":"https://api.github.com/repos/influxdata/influxdb/issues/9087/events","html_url":"https://github.com/influxdata/influxdb/issues/9087","id":272622964,"number":9087,"title":"Unable to take \"INTEGRAL\" of a math-function","user":{"login":"drmclean","id":8614203,"avatar_url":"https://avatars1.githubusercontent.com/u/8614203?v=4","gravatar_id":"","url":"https://api.github.com/users/drmclean","html_url":"https://github.com/drmclean","followers_url":"https://api.github.com/users/drmclean/followers","following_url":"https://api.github.com/users/drmclean/following{/other_user}","gists_url":"https://api.github.com/users/drmclean/gists{/gist_id}","starred_url":"https://api.github.com/users/drmclean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drmclean/subscriptions","organizations_url":"https://api.github.com/users/drmclean/orgs","repos_url":"https://api.github.com/users/drmclean/repos","events_url":"https://api.github.com/users/drmclean/events{/privacy}","received_events_url":"https://api.github.com/users/drmclean/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-11-09T16:17:27Z","updated_at":"2017-11-15T20:48:27Z","closed_at":null,"author_association":"NONE","body":"We store `voltage` and `current` in our influx cluster. \r\n\r\nWe can calculate power like this:\r\n\r\n`SELECT voltage*current as power FROM <db>.<rp>.<meas> WHERE <series-tag>`\r\n\r\nWe want to be able to calculate energy like this:\r\n\r\n`SELECT integral(voltage * current) as energy FROM <db>.<rp>.<meas> WHERE <series-tag> and <time>`\r\n\r\nHowever such a query gives the followig:\r\n\r\n`ERR: SELECT integral(current * voltage) FROM <db>.<rp>.<meas> WHERE <series-tag> [panic:interface conversion: influxql.Expr is *influxql.BinaryExpr, not *influxql.VarRef]`\r\n\r\nA more standard query such as:\r\n\r\n`SELECT integral(voltage) as energy FROM <db>.<rp>.<meas> WHERE <series-tag> and <time>`\r\n\r\nworks a expected.\r\n\r\nIs it possible to achieve the result I want?\r\nIs it possible to do math inside the new INTEGRAL function?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/comments/344723555","html_url":"https://github.com/influxdata/influxdb/issues/9087#issuecomment-344723555","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/9087","id":344723555,"user":{"login":"jsternberg","id":1212129,"avatar_url":"https://avatars2.githubusercontent.com/u/1212129?v=4","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":"2017-11-15T20:48:27Z","updated_at":"2017-11-15T20:48:27Z","author_association":"CONTRIBUTOR","body":"So I haven't fully read the issue (just skimmed it) so I apologize if this isn't helpful (and promise to read it more fully), but you can likely use subqueries for this. Part of the reason why we didn't add `integral(max(value))` was because subqueries existed after we implemented integral while subqueries didn't exist when we were adding things like `derivative()`.\r\n\r\nIf you need to do math like `current * voltage`, I think you can also do that with subqueries. I think something like this: `SELECT integral(power) FROM (SELECT current * voltage as power FROM <db>.<rp>.<meas> WHERE <series-tag>)`"}}
{"actor":{"display_login":"jsternberg"}}