VictoriaMetrics/app/vmctl
Zhu Jiekun 63df2205cf
vmctl: fixed import duplicate data when query result contains multiple series (#7330)
### Describe Your Changes

Fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/7301

When querying with condition like `WHERE a=1` (looking for series A),
InfluxDB can return data with the tag `a=1` (series A) and data with the
tag `a=1,b=1` (series B).

However, series B is will be queried later and it's data should not be
combined into series A's data.

This PR filter those series that are not identical to the original query
condition.

For table `example`:
```
// time                           host    region  value
// ----                           ----    ------  -----
// 2024-10-25T02:12:13.469720983Z serverA us_west 0.64
// 2024-10-25T02:12:21.832755213Z serverA us_west 0.75
// 2024-10-25T02:12:32.351876479Z serverA         0.88
// 2024-10-25T02:12:37.766320484Z serverA         0.95
```

The query for series A (`example_value{host="serverA"}`) and result will
be:
```SQL
SELECT * FROM example WHERE host = "serverA"
```
```json
{
	"results": [{
		"statement_id": 0,
		"series": [{
			"name": "cpu",
			"columns": ["time", "host", "region", "value"],
			"values": [
				["2024-10-25T02:12:13.469720983Z", "serverA", "us_west", 0.64],
				["2024-10-25T02:12:21.832755213Z", "serverA", "us_west", 0.75],
				["2024-10-25T02:12:32.351876479Z", "serverA", null, 0.88],
				["2024-10-25T02:12:37.766320484Z", "serverA", null, 0.95]
			]
		}]
	}]
}
```

We need to abandon `values[0]` and `values[1]` because the value of
**unwanted** column `region` is not null.

As for series B (`example_value{host="serverA", region="us_west"}`), no
change needed since the query filter out unwanted rows already.

### Note
This is a draft PR for verifying the fix.

### Checklist

The following checks are **mandatory**:

- [x] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).

---------

Signed-off-by: hagen1778 <roman@victoriametrics.com>
Co-authored-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit f16a58f14c)
2024-11-06 13:58:19 +01:00
..
auth app/vmctl: add support of basic auth and barer token (#3921) 2023-03-12 00:08:04 -08:00
backoff vmctl: add --backoff-retries, --backoff-factor, --backoff-min-duration global command-line flags (#6639) 2024-08-03 19:34:03 +02:00
barpool vmctl: disable progress bar for prometheus snapshot migrations (#6385) 2024-06-10 12:41:44 +02:00
deployment all: suppress InvalidDefaultArgInFrom warning emitted by docker build when building Docker packages via make package-* command 2024-09-03 14:05:43 +02:00
influx vmctl: fixed import duplicate data when query result contains multiple series (#7330) 2024-11-06 13:58:19 +01:00
limiter vmctl: add option to rate limit data transfer speed 2022-01-06 23:14:22 +02:00
multiarch app/*/multiarch: return back empty value for TARGETARCH 2024-09-06 18:15:22 +02:00
native app/vmctl: break explore phase in vm-native mode by time intervals 2024-03-25 15:42:24 +01:00
opentsdb all: consistently use 'any' instead of 'interface{}' 2024-07-10 00:23:26 +02:00
prometheus app/vmctl: switch from table-driven tests to f-tests 2024-07-12 22:45:49 +02:00
remoteread app/vmctl: fix arguments order in httputils.TLSConfig 2024-03-17 23:22:08 +02:00
stepper app/vmctl: switch from table-driven tests to f-tests 2024-07-12 22:45:49 +02:00
terminal all: cleanup: remove // +build ... lines, since they are no longer needed after Go1.17, and the minimum supported Go version for VictoriaMetrics source code is Go1.20 2023-11-13 19:15:42 +01:00
utils app/vlinsert: support _time field without timezone information during data ingestion 2024-09-26 12:50:14 +02:00
vm vmctl: add --backoff-retries, --backoff-factor, --backoff-min-duration global command-line flags (#6639) 2024-08-03 19:34:03 +02:00
flags.go vmctl: add --backoff-retries, --backoff-factor, --backoff-min-duration global command-line flags (#6639) 2024-08-03 19:34:03 +02:00
influx.go vmctl: disable progress bar for prometheus snapshot migrations (#6385) 2024-06-10 12:41:44 +02:00
main.go lib/httputils: parse URL before creating HTTP transport (#6820) 2024-08-16 11:34:49 +02:00
Makefile Add build support for loong64 (#6222) 2024-05-10 14:32:05 +02:00
opentsdb.go app/vmctl: fixes opentsdb source metric tags 2024-10-17 11:09:01 -03:00
prometheus.go vmctl: disable progress bar for prometheus snapshot migrations (#6385) 2024-06-10 12:41:44 +02:00
prometheus_test.go app/vmalert: switch from table-driven tests to f-tests 2024-07-12 22:45:50 +02:00
README.md all: replace old https://docs.victoriametrics.com/vmctl.html url with the new one - https://docs.victoriametrics.com/vmctl/ 2024-04-18 01:54:16 +02:00
remoteread.go vmctl: disable progress bar for prometheus snapshot migrations (#6385) 2024-06-10 12:41:44 +02:00
utils.go vmctl: disable progress bar for prometheus snapshot migrations (#6385) 2024-06-10 12:41:44 +02:00
vm_native.go app/vmctl: fix match expression for vm-native protocol with --vm-native-disable-per-metric-migration flag enabled (#7310) 2024-10-24 15:49:11 +02:00

See vmctl docs here.

vmctl docs can be edited at docs/vmctl.md.