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

The logical table in the metric engine does not follow the defined column order when insert #5062

Open
killme2008 opened this issue Nov 27, 2024 · 4 comments
Labels
C-bug Category Bugs

Comments

@killme2008
Copy link
Contributor

What type of bug is this?

Unexpected error

What subsystems are affected?

Storage Engine

Minimal reproduce step

For example, let's create a logical table and try to insert some data:

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

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

INSERT INTO test_ttl VALUES
       (now(), 1, 'host1'),
       (now(), 2, 'host2'),
       (now(), 3, 'host3');

It fails right now:

Error: 3001(EngineExecuteQuery), Cast error: Cannot cast string ‘host1’ to value of Float64 type

I must specify the columns in insert statement:

INSERT INTO test_ttl(ts, val, host) VALUES
       (now(), 1, 'host1'),
       (now(), 2, 'host2'),
       (now(), 3, 'host3');

What did you expect to see?

Sucess to insert

What did you see instead?

Fails with

Error: 3001(EngineExecuteQuery), Cast error: Cannot cast string ‘host1’ to value of Float64 type

What operating system did you use?

All

What version of GreptimeDB did you use?

v0.10.2

Relevant log output and stack trace

No response

@killme2008 killme2008 added the C-bug Category Bugs label Nov 27, 2024
@NiwakaDev
Copy link
Collaborator

NiwakaDev commented Dec 3, 2024

@killme2008

I'm interested in the issue.

This lines seems to result in the bug. In creating a logical table, this is executed.

Once removed the line, the bug doesn't happen. But, I don't know whether it is fine to remove it.

@killme2008
Copy link
Contributor Author

@killme2008

I'm interested in the issue.

This lines seems to result in the bug. In creating a logical table, this is executed.

Once removed the line, the bug doesn't happen. But, I don't know whether it is fine to remove it.

Thank you for your investigation. @waynexia is the designer of the metric engine. What are your thoughts on @NiwakaDev's suggestion?

@evenyag
Copy link
Contributor

evenyag commented Dec 16, 2024

The metric engine requires this to ensure the logical table and the physical table have the same column order and the datanode can create the same column id for the columns.

@waynexia
Copy link
Member

This is intended behavior. Metric engine will send its updated schema to metasrv in the response, for metasrv to keep in sync with metric engine.

But this behavior might not be the most optimal option. As the user interface seems hard to use. We can change it if needed by adding a pre-create request round-trip between metasrv and metric engine to negotiate the proper schema and column id.

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

No branches or pull requests

4 participants