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

feat: implement DESCRIBE TABLE #558

Merged
merged 5 commits into from
Nov 18, 2022

Conversation

morigs
Copy link
Contributor

@morigs morigs commented Nov 17, 2022

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Support DESC[RIBE] TABLE sql clause. Returns following info about table columns: name, type, nullable, default, semantic type.

Not sure about Display for Value implementation. Perhaps it should be more sql-ish

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

Resolves #534

Support DESC[RIBE] TABLE sql clause. Returns following info about table columns: name, type, nullable, default, semantic type.
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #558 (232b816) into develop (8faa6b0) will increase coverage by 0.06%.
The diff coverage is 93.75%.

@@             Coverage Diff             @@
##           develop     #558      +/-   ##
===========================================
+ Coverage    86.38%   86.44%   +0.06%     
===========================================
  Files          398      399       +1     
  Lines        50042    50610     +568     
===========================================
+ Hits         43229    43752     +523     
- Misses        6813     6858      +45     
Flag Coverage Δ
rust 86.44% <93.75%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/datanode/src/instance/sql.rs 86.58% <0.00%> (-4.45%) ⬇️
src/datanode/src/sql.rs 73.50% <0.00%> (-0.99%) ⬇️
src/frontend/src/instance.rs 73.31% <0.00%> (ø)
src/frontend/src/instance/distributed.rs 83.98% <0.00%> (+0.07%) ⬆️
src/query/src/datafusion/planner.rs 82.22% <ø> (ø)
src/query/src/error.rs 24.00% <0.00%> (+24.00%) ⬆️
src/sql/src/statements.rs 80.62% <ø> (ø)
src/sql/src/statements/statement.rs 48.27% <0.00%> (-5.58%) ⬇️
src/datatypes/src/schema/constraint.rs 97.38% <80.00%> (-0.47%) ⬇️
src/sql/src/parser.rs 71.69% <86.20%> (+1.78%) ⬆️
... and 17 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/query/src/sql.rs Show resolved Hide resolved
src/sql/src/statements/describe.rs Show resolved Hide resolved
src/sql/src/parser.rs Show resolved Hide resolved
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @morigs ! This patch is very neat 👍

I've tried it in my local, it works as expect:

mysql> desc table t;
+--------+-----------+------+---------------------+---------------+
| Field  | Type      | Null | Default             | Semantic Type |
+--------+-----------+------+---------------------+---------------+
| host   | String    | NO   |                     | PRIMARY KEY   |
| ts     | Timestamp | NO   | current_timestamp() | TIME INDEX    |
| cpu    | Float64   | NO   | 0                   | VALUE         |
| memory | Float64   | YES  |                     | VALUE         |
+--------+-----------+------+---------------------+---------------+

(created by)

mysql> CREATE TABLE t (
    ->   host STRING,
    ->   ts TIMESTAMP DEFAULT current_timestamp,
    ->   cpu DOUBLE DEFAULT 0,
    ->   memory DOUBLE NULL,
    ->   TIME INDEX (ts),
    ->   PRIMARY KEY(host)) ENGINE=mito WITH(regions=1);
Query OK, 1 row affected (0.06 sec)

Not sure about Display for Value implementation. Perhaps it should be more sql-ish

Implement Display for Value looks good to me. In another patch I also use Display to draw SQL result table (here https://github.com/GreptimeTeam/greptimedb/blob/integration-test/tests/runner/src/util.rs#L3)

src/query/src/sql.rs Outdated Show resolved Hide resolved
src/datatypes/src/value.rs Outdated Show resolved Hide resolved
@morigs
Copy link
Contributor Author

morigs commented Nov 17, 2022

Thanks for the feedback. I'll fix this soon

@morigs morigs requested review from v0y4g3r and removed request for evenyag November 17, 2022 19:40
@v0y4g3r
Copy link
Contributor

v0y4g3r commented Nov 18, 2022

Thanks for the feedback. I'll fix this soon

Currently I'm Ok with the catalog/schema name issue and marked these are resolved. Please fix other comments and we can merge this PR as soon as possible. Don't hesitate to reach us if you need any help!

Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@v0y4g3r v0y4g3r merged commit e1f3262 into GreptimeTeam:develop Nov 18, 2022
paomian pushed a commit to paomian/greptimedb that referenced this pull request Oct 19, 2023
Also need to support describe table in other catalog/schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement DESCRIBE TABLE clause
3 participants