Influxdb: [Feature Request] Add "CASE WHEN"/value decoding functionality

Created on 8 Mar 2018  路  5Comments  路  Source: influxdata/influxdb

Feature Request

__Proposal:__ Add CASE WHEN to the query language. For example, when monitoring the status of a service, I track status codes. I'd like to be able to query a translation for the status codes. So if I have a svchealth measurement which contains the svcid tag and the statuscode value, I'd be able to do query the translation of statuscode this way:

select 
  svcid, 
  statuscode, 
  case 
    when statuscode = 1 then 'running'
    when statuscode = 2 then 'paused'
    when statuscode = 3 then 'stopped'
    else 'unknown'
  end as statustext
from svchealth

Or a simpler variant - a decode function which would work similarly:

select
  svcid,
  statuscode,
  decode(statuscode,
    1, 'running',
    2, 'paused',
    3, 'stopped',
    'unknown') as statustext
from svchealth

__Current behavior:__ The feature does not exist, and I have to store statustext alongside statuscode which leads to denormalization

__Desired behavior:__ The ability to decode values

__Use case:__ Show meaningful text in visualization tools

1.x kinfeature-request preview wontfix

All 5 comments

+1

+1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.

Please re-open, this feature is really important. _Lots_ of data, especially IIOT data, has enumerations that are ideally mapped at query time.

Was this page helpful?
0 / 5 - 0 ratings