influxdata / influxdata/influxdb

Static value in SELECT query (v1.8)

Open
#23,281 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Hello!
I need add to SELECT query static value to show it in Grafana, but I can't find the way how to do it in InfluxDB. I **don't interested** in adding tag or field. Is it possible?

__Steps to reproduce:__

1. Insert the example values
```sql
INSERT staff,position=worker name="John"
INSERT staff,position=worker name="Michael"
INSERT staff,position=worker name="Frank"
```

__Expected behavior:__
Query with static value and data like in SQLite3, MySQL, etc.

Query:
```sql
SELECT 'IT' AS "data_source", * FROM "staff"
```

Data
```
name: staff
time data_source name position
---- ---- ---- ----
1650305100000000000 IT John worker
1650305100000000000 IT Michael worker
1650305100000000000 IT Frank worker
```

__Actual behavior:__

Error:
```
ERR: field must contain at least one variable
```

__Environment info:__

* System info: Ubuntu 20.04
* InfluxDB version: 1.8 (Docker)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the SELECT query against the example staff measurement in an InfluxDB 1.8 environment and confirm the “field must contain at least one variable” error. Review the query behavior for static expressions and define completion as returning the requested data_source column alongside the existing fields without adding a tag or field.

Written by the indexing model from the issue text.

Assessment

Tech stack
grafana, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.