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

Create columns with tag semantic type #2183

Closed
killme2008 opened this issue Aug 16, 2023 · 5 comments
Closed

Create columns with tag semantic type #2183

killme2008 opened this issue Aug 16, 2023 · 5 comments
Labels
C-enhancement Category Enhancements good first issue Good for newcomers

Comments

@killme2008
Copy link
Contributor

killme2008 commented Aug 16, 2023

What type of enhancement is this?

API improvement, User experience

What does the enhancement do?

If the users write data by influxdb, opentsdb or Prometheus remote write, GreptimeDB will auto-create the table with the correct semantic types:

  • SemanticType::Tag for tags(or labels in Prometheus)
  • SematicType::Field for fields(or values)
  • SematicType::Timestamp for time index column

But when using SQL to create table, it doesn't provide a way to create columns with tag semantic type,all the columns not in the primary key except time index are field semantic type.

I think we can provide a SQL extension to create tables with tag columns, for example:

CREATE TABLE IF NOT EXISTS system_metrics (
    host STRING TAG,
    idc STRING TAG,
    cpu_util DOUBLE,
    memory_util DOUBLE,
    disk_util DOUBLE,
    ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    TIME INDEX(ts)
);

It's the same as:

CREATE TABLE IF NOT EXISTS system_metrics (
    host STRING,
    idc STRING,
    cpu_util DOUBLE,
    memory_util DOUBLE,
    disk_util DOUBLE,
    ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    primary key(host, idc),
    TIME INDEX(ts)
);

Then the host and idc will be created with tag semantics. The columns except time index without TAG option will be created with field semantics.

Implementation challenges

  • Make the column option parser to support tag option.
  • Pass the tag semantic type to create table request.
@killme2008 killme2008 added C-enhancement Category Enhancements good first issue Good for newcomers labels Aug 16, 2023
@killme2008 killme2008 modified the milestone: v0.4 Sep 1, 2023
@NiwakaDev
Copy link
Collaborator

I'd like to work on this issue, but do I need to wait until migrate-region-server is merged?

@MichaelScofield
Copy link
Collaborator

@NiwakaDev You can checkout a branch from migrate-region-server and implement the feature on top of it. We will finally make the migrate-region-server branch the new "develop" branch.

@killme2008
Copy link
Contributor Author

Thank you. But we don't want this feature yet. It needs more discussion.
The primary key constraint looks good enough to represent the columns in tag semantics and it contains the columns ordering info.
Not sure if we need a new syntax for it. As you know, less is more.

@NiwakaDev
Copy link
Collaborator

Until this discussion land, I think that we can add a section about relationship between primary keys and tags in the document so that user can easily understand:
GreptimeTeam/docs#452

@killme2008
Copy link
Contributor Author

Until this discussion land, I think that we can add a section about relationship between primary keys and tags in the document so that user can easily understand: GreptimeTeam/docs#452

Can't agree more with it, thank u.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants