Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect semantic_type of the physical table. #3758

Closed
WenyXu opened this issue Apr 20, 2024 · 0 comments · Fixed by #3770
Closed

Incorrect semantic_type of the physical table. #3758

WenyXu opened this issue Apr 20, 2024 · 0 comments · Fixed by #3770
Assignees
Labels
C-bug Category Bugs

Comments

@WenyXu
Copy link
Member

WenyXu commented Apr 20, 2024

          > We can start by mocking the usage of GreptimeDB as Prometheu's backend(https://docs.greptime.com/user-guide/write-data/prometheus)

We always create two physical table with two columns: a timestamp(millisecond, datatypes) column and a value(double) column. The datatype is following the Prometheus document).

i.e.,

CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");

Then we will get a physical table.

select column_name, data_type, semantic_type  from information_schema.columns where table_name = 'phy';
+-------------+--------------+---------------+
| column_name | data_type    | semantic_type |
+-------------+--------------+---------------+
| ts          | timestamp(3) | TIMESTAMP     |
| val         | double       | FIELD         |
+-------------+--------------+---------------+

Then, the fuzz target randomly creates many logical tables and validates the datatypes of the logical and physical table.

e.g.,

CREATE TABLE t2 (ts timestamp time index, val double, host string, idc string, primary key(idc, host)) engine = metric with ("on_physical_table" = "phy");

Validating the datatypes of the physical table.

select column_name, data_type, semantic_type, column_default from information_schema.columns where table_name = 'phy'; 
+-------------+-----------------+---------------+----------------+
| column_name | data_type       | semantic_type | column_default |
+-------------+-----------------+---------------+----------------+
| ts          | timestamp(3)    | FIELD         | NULL           |
| val         | double          | FIELD         | NULL           |
| __table_id  | int unsigned    | TAG           | NULL           |
| __tsid      | bigint unsigned | TAG           | NULL           |
| host        | string          | TAG           | NULL           |
| idc         | string          | TAG           | NULL           |
+-------------+-----------------+---------------+----------------+

Validating the datatypes of the logical table.

select column_name, data_type, semantic_type, column_default from information_schema.columns where table_name = 't2';
+-------------+--------------+---------------+----------------+
| column_name | data_type    | semantic_type | column_default |
+-------------+--------------+---------------+----------------+
| host        | string       | TAG           | NULL           |
| idc         | string       | TAG           | NULL           |
| ts          | timestamp(3) | TIMESTAMP     | NULL           |
| val         | double       | FIELD         | NULL           |
+-------------+--------------+---------------+----------------+

BTW, there is the bug. The semantic_type in the 1st row should be TIMESTAMP.

select column_name, data_type, semantic_type, column_default from information_schema.columns where table_name = 'phy'; 
+-------------+-----------------+---------------+----------------+
| column_name | data_type       | semantic_type | column_default |
+-------------+-----------------+---------------+----------------+
| ts          | timestamp(3)    | FIELD         | NULL           |
| val         | double          | FIELD         | NULL           |
| __table_id  | int unsigned    | TAG           | NULL           |
| __tsid      | bigint unsigned | TAG           | NULL           |
| host        | string          | TAG           | NULL           |
| idc         | string          | TAG           | NULL           |
+-------------+-----------------+---------------+----------------+

Originally posted by @WenyXu in #3756 (comment)

@WenyXu WenyXu added C-bug Category Bugs O-fuzz Found by fuzz tests and removed O-fuzz Found by fuzz tests labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category Bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants