Two tables returned with identical group keys

Can anyone help me figure out this issue? I restructured my database, and have to fill in historical data into the new format. For some reason, the historical data comes out in a different table when I query it, even though all the values in the group key are identical. If I call group() using the same group key, they all end up in 1 table, but I don’t want to have to do that every time I query the database.

Here’s the flux that generates that result:

from(bucket: "power_circuit_lores")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "kw")
  |> filter(fn: (r) => r["_field"] == "pair_min")
  |> filter(fn: (r) => r["circuit_pair_id"] == "3303")
  |> yield(name: "mean")

Running on InfluxDB OSS 2.6.1

I tried calling distinct on each of my columns in the group key to see if there was some formatting difference between some of the values, but I get this error, presumably because there are two tables with the same group key values.

runtime error @8:6-8:30: unique: unique found duplicate table with key: {_field=pair_min,_measurement=kw,_start=2023-02-01T20:20:53.847502436Z,_stop=2023-03-03T20:20:53.847502436Z,account_id=52,circuit_pair_id=3303,facility_id=2}

Curiously, when graphing, I only get one color line in the graph, as if it’s a single series, (which of course it should be,) but it connects the beginning to the end in a loop.

EDIT: Not quite a full loop. It is a single line, but there is a break between the old and new data when I zoom in.

If I run group on the same group key, then sort, I now get just one table and the correct graph. I tried piping that query to the same bucket, to overwrite the existing data, but that didn’t help anything.

And now some more weirdness, which perhaps helps figure out what is going on here? While trying to unify the points, I somehow got two points into the same bucket with the same time and tags (but are somehow part of different series.) I thought that when adding a point with the same time and tag it would overwrite the old one?

from(bucket: "power_circuit_lores")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_field"] == "ckt_max")
  |> filter(fn: (r) => r["circuit_id"] == "3304")
  |> filter(fn: (r) => r["_time"] == 2023-03-01T22:00:00.000Z)
  |> yield(name: "mean")

Hello @gazpachoking,
I thought so too.
This is very strange behavior.
Can you please create an issue here?

Created an issue here Points in the same series being returned in separate tables (plus duplicate points with _all_ values matching) · Issue #24127 · influxdata/influxdb · GitHub

1 Like

I probably have the same issue here. Were you able to solve? It seems the issue is still opened in GitHub…

Nope, didn’t notice it got solved, I resorted to just manually running group and sort on every query to make sure I only got one table.

In fact it has NOT been solved, the issue is still opened.