mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-27 18:30:38 +00:00
feat: support table level comment (#4042)
* feat: support table level comment * use constants Signed-off-by: tison <wander4096@gmail.com> --------- Signed-off-by: tison <wander4096@gmail.com> Co-authored-by: tison <wander4096@gmail.com>
This commit is contained in:
@@ -59,7 +59,7 @@ use store_api::metric_engine_consts::{LOGICAL_TABLE_METADATA_KEY, METRIC_ENGINE_
|
||||
use substrait::{DFLogicalSubstraitConvertor, SubstraitPlan};
|
||||
use table::dist_table::DistTable;
|
||||
use table::metadata::{self, RawTableInfo, RawTableMeta, TableId, TableInfo, TableType};
|
||||
use table::requests::{AlterKind, AlterTableRequest, TableOptions};
|
||||
use table::requests::{AlterKind, AlterTableRequest, TableOptions, COMMENT_KEY};
|
||||
use table::TableRef;
|
||||
|
||||
use super::StatementExecutor;
|
||||
@@ -1142,7 +1142,7 @@ fn create_table_info(
|
||||
};
|
||||
|
||||
let desc = if create_table.desc.is_empty() {
|
||||
None
|
||||
create_table.table_options.get(COMMENT_KEY).cloned()
|
||||
} else {
|
||||
Some(create_table.desc.clone())
|
||||
};
|
||||
|
||||
@@ -54,6 +54,7 @@ pub fn validate_table_option(key: &str) -> bool {
|
||||
WRITE_BUFFER_SIZE_KEY,
|
||||
TTL_KEY,
|
||||
STORAGE_KEY,
|
||||
COMMENT_KEY,
|
||||
// file engine keys:
|
||||
FILE_TABLE_LOCATION_KEY,
|
||||
FILE_TABLE_FORMAT_KEY,
|
||||
@@ -80,6 +81,7 @@ pub struct TableOptions {
|
||||
pub const WRITE_BUFFER_SIZE_KEY: &str = "write_buffer_size";
|
||||
pub const TTL_KEY: &str = "ttl";
|
||||
pub const STORAGE_KEY: &str = "storage";
|
||||
pub const COMMENT_KEY: &str = "comment";
|
||||
|
||||
impl TableOptions {
|
||||
pub fn try_from_iter<T: ToString, U: IntoIterator<Item = (T, T)>>(
|
||||
|
||||
@@ -204,3 +204,36 @@ DROP table `ExcePTuRi`;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE if not exists monitor (
|
||||
host STRING,
|
||||
ts TIMESTAMP(9) DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
|
||||
cpu FLOAT64 DEFAULT 0,
|
||||
memory FLOAT64,
|
||||
PRIMARY KEY(host)) ENGINE=mito WITH(COMMENT='create by human');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SHOW CREATE TABLE monitor;
|
||||
|
||||
+---------+-----------------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+---------+-----------------------------------------------------------+
|
||||
| monitor | CREATE TABLE IF NOT EXISTS "monitor" ( |
|
||||
| | "host" STRING NULL, |
|
||||
| | "ts" TIMESTAMP(9) NOT NULL DEFAULT current_timestamp(), |
|
||||
| | "cpu" DOUBLE NULL DEFAULT 0, |
|
||||
| | "memory" DOUBLE NULL, |
|
||||
| | TIME INDEX ("ts"), |
|
||||
| | PRIMARY KEY ("host") |
|
||||
| | ) |
|
||||
| | |
|
||||
| | ENGINE=mito |
|
||||
| | WITH( |
|
||||
| | comment = 'create by human' |
|
||||
| | ) |
|
||||
+---------+-----------------------------------------------------------+
|
||||
|
||||
DROP TABLE monitor;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -81,3 +81,14 @@ DROP TABLE test_like_1;
|
||||
DROP TABLE test_like_2;
|
||||
|
||||
DROP table `ExcePTuRi`;
|
||||
|
||||
CREATE TABLE if not exists monitor (
|
||||
host STRING,
|
||||
ts TIMESTAMP(9) DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
|
||||
cpu FLOAT64 DEFAULT 0,
|
||||
memory FLOAT64,
|
||||
PRIMARY KEY(host)) ENGINE=mito WITH(COMMENT='create by human');
|
||||
|
||||
SHOW CREATE TABLE monitor;
|
||||
|
||||
DROP TABLE monitor;
|
||||
|
||||
Reference in New Issue
Block a user