influxdata / influxdata/influxdb

Group by tag produces unexpected extra tables

Open
#15,907 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

When grouping by tag and time, some tags are duplicated and get their own table in the returned data. The tags are seemingly the same.

Impact of the issue is that when displaying the measurement in Grafana, multiple series with the same name are displayed.

Hunch on the cause: if there's a dash in the name of the tag, the duplication occurs.

__Steps to reproduce:__

Imagine a measurement where I have power measurements, each datapoint has a name tag on it. The name tags are one of:

```
> show series from "sonoff"
key
---
sonoff,name=fridge
sonoff,name=sonoff-test1
sonoff,name=sonoff-test2
sonoff,name=zeus
```

Steps to repro:

1. Execute query `SELECT integral("power", 1h) FROM "sonoff" GROUP BY "name",time(1h)`

__Expected behavior:__
Expecting four tables, each with data for the individual tag, grouped by day.

__Actual behavior:__
Instead of receiving 4 tables, I am receiving 6 tables. Data for some tags are split into two separate tables. See `sonoff-test1` and `sonoff-test2`.

```
> SELECT integral("power", 1h) FROM "sonoff" GROUP BY "name",time(1d)
name: sonoff
tags: name=sonoff-test1
time integral
---- --------
1572739200000000000 0
1573084800000000000 134.12802563797499
1573171200000000000 1403.4860907628959

name: sonoff
tags: name=sonoff-test2
time integral
---- --------
1572739200000000000 21.586268448758343
1572825600000000000 5513.367689052895
1572912000000000000 7568.589875131045
1572998400000000000 7186.295171349486
1573084800000000000 7130.923582409216
1573171200000000000 5053.789631408752
1573257600000000000 5507.0490514320745
1573344000000000000 7067.010522639567
1573430400000000000 7107.880787942374
1573516800000000000 7201.345105608751
1573603200000000000 7430.035949420228

name: sonoff
tags: name=zeus
time integral
---- --------
1573257600000000000 1002.8006321462849
1573344000000000000 2211.8250559228195
1573430400000000000 2188.313785892997
1573516800000000000 2212.0553204324065
1573603200000000000 2235.7637748647617
1573689600000000000 1055.578516248275

name: sonoff
tags: name=sonoff-test2
time integral
---- --------
1573689600000000000 3704.5608035766477

name: sonoff
tags: name=sonoff-test1
time integral
---- --------
1573257600000000000 872.9956244698335

name: sonoff
tags: name=fridge
time integral
---- --------
1573689600000000000 180.27985350614858
```

__Environment info:__

* System info: `Windows Server 2019 x64`
* InfluxDB version: `InfluxDB v1.7.6 (git: 1.7 01c8dd416270f424ab0c40f9291e269ac6921964)`
* Other relevant environment details: Container runtime, disk info, etc

__Config:__
Copy any non-default config values here or attach the full config as a gist or file.

*No relevant non-default config*

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported InfluxQL query against the provided measurement and compare grouping for tag values containing dashes. Trace the grouping result that produces separate tables for sonoff-test1 and sonoff-test2; done means the query returns four tables, with each tag's data kept together.

Written by the indexing model from the issue text.

Assessment

Tech stack
grafana
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.