influxdata / influxdata/influxdb

Add "CASE WHEN"/value decoding functionality

Open
#23,376 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Creating a new issue as #9528 was closed.

**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

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the query-language parser and execution paths, then determine whether CASE WHEN, decode, or both fit the project’s query design. Done would mean a decided syntax and implementation plan with coverage for the status-code examples.

Written by the indexing model from the issue text.

Assessment

Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.