1

According to CnosDB's insert syntax, I am trying to write duplicate data points (same timestamp + same tag but different field values in different batch), these data points should have been merged together into one data point. I am using v2.0.1.

See my lab below:

  1. Create a table with two tags:
CREATE TABLE test (
   a BIGINT,
   b BIGINT,
   c BIGINT,
   TAGS(id,name)
);

  1. Insert a data point with field "a" ONLY
INSERT INTO test (TIME, id,a) VALUES('2023-03-28 16:00:00', '1',100);

SELECT * FROM test;

Result:

time id name a b c
2023-03-28T16:00:00.000000000 1 100
  1. Insert a data point with field "b" ONLY
INSERT INTO test (TIME, id,b) VALUES('2023-03-28 16:00:00', '1',200);

SELECT * FROM test;

Result:

time id name a b c
2023-03-28T16:00:00.000000000 1 100 200
  1. Insert a data point with field "a"(same), "b"(same), "c"(new)
INSERT INTO test (TIME, id,a,b,c) VALUES('2023-03-28 16:00:00', '1',100,200,300);

SELECT * FROM test;

Result:

time id name a b c
2023-03-28T16:00:00.000000000 1 100 200 300
  1. Insert a data point with field "a"(different) ONLY
INSERT INTO test (TIME, id,a) VALUES('2023-03-28 16:00:00', '1',110);

SELECT * FROM test;

Result:

time id name a b c
2023-03-28T16:00:00.000000000 1 100 200 300
2023-03-28T16:00:00.000000000 1 110

Expected result:

time id name a b c
2023-03-28T16:00:00.000000000 1 110 200 300
  1. Insert a data point with field "a"(different), "b"(different), "c"(different)
INSERT INTO test (TIME, id,a,b,c) VALUES('2023-03-28 16:00:00', '1',120,220,320);

SELECT * FROM test;

Result:

time id name a b c
2023-03-28T16:00:00.000000000 1 100 200 300
2023-03-28T16:00:00.000000000 1 110 220 320
2023-03-28T16:00:00.000000000 1 120

Expected result:

time id name a b c
2023-03-28T16:00:00.000000000 1 120 220 320

Any workaround here?

Munin
  • 1,576
  • 2
  • 19

1 Answers1

2

This looks like a v2.0.1 bug.

I tested on v2.2.0, the result is in line with your expectations

CREATE TABLE test (
   a BIGINT,
   b BIGINT,
   c BIGINT,
   TAGS(id,name)
);
INSERT INTO test (TIME, id,a,b,c) VALUES('2023-03-28 16:00:00', '1',100,200,300);

Result:

SELECT * FROM test;
+---------------------+----+------+-----+-----+-----+
| time                | id | name | a   | b   | c   |
+---------------------+----+------+-----+-----+-----+
| 2023-03-28T16:00:00 | 1  |      | 100 | 200 | 300 |
+---------------------+----+------+-----+-----+-----+

INSERT INTO test (TIME, id,a) VALUES('2023-03-28 16:00:00', '1',110);

Result:

SELECT * FROM test;
+---------------------+----+------+-----+-----+-----+
| time                | id | name | a   | b   | c   |
+---------------------+----+------+-----+-----+-----+
| 2023-03-28T16:00:00 | 1  |      | 110 | 200 | 300 |
+---------------------+----+------+-----+-----+-----+

INSERT INTO test (TIME, id,a,b,c) VALUES('2023-03-28 16:00:00', '1',120,220,320);

Result:

SELECT * FROM test;
+---------------------+----+------+-----+-----+-----+
| time                | id | name | a   | b   | c   |
+---------------------+----+------+-----+-----+-----+
| 2023-03-28T16:00:00 | 1  |      | 120 | 220 | 320 |
+---------------------+----+------+-----+-----+-----+

The bug has been fixed at https://github.com/cnosdb/cnosdb/pull/761

ZuoTiJia
  • 161
  • 5