From 92a9802343324a9c0707234456e25a39e6f9bfa0 Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Wed, 29 Nov 2023 14:40:10 +0800 Subject: [PATCH] feat: canonicalize all unquoted identifier to lowercase (#2828) * feat: canonicalize all unquoted identifier to lowercase Signed-off-by: Ruihang Xia * add more tests Signed-off-by: Ruihang Xia * test altering table Signed-off-by: Ruihang Xia * primary key declare Signed-off-by: Ruihang Xia * fix primary key declare Signed-off-by: Ruihang Xia * partition by and time index Signed-off-by: Ruihang Xia * remove redundent call to canonicalize Signed-off-by: Ruihang Xia --------- Signed-off-by: Ruihang Xia --- src/sql/src/parser.rs | 24 ++++++ src/sql/src/parsers/alter_parser.rs | 13 ++-- src/sql/src/parsers/copy_parser.rs | 3 +- src/sql/src/parsers/create_parser.rs | 29 +++++-- src/sql/src/parsers/describe_parser.rs | 3 +- src/sql/src/parsers/drop_parser.rs | 3 +- src/sql/src/parsers/show_parser.rs | 3 +- src/sql/src/parsers/truncate_parser.rs | 3 +- .../standalone/common/alter/add_col.result | 17 +++++ .../cases/standalone/common/alter/add_col.sql | 4 + .../standalone/common/alter/drop_col.result | 6 +- .../standalone/common/alter/drop_col.sql | 4 +- .../common/alter/rename_table.result | 43 +++++++++++ .../standalone/common/alter/rename_table.sql | 17 +++++ .../create/upper_case_table_name.result | 75 ++++++++++++++++++- .../common/create/upper_case_table_name.sql | 36 ++++++++- .../standalone/common/delete/delete.result | 24 ++++++ .../cases/standalone/common/delete/delete.sql | 13 ++++ .../order/order_variable_size_payload.result | 12 +-- .../order/order_variable_size_payload.sql | 12 +-- .../common/truncate/truncate.result | 24 ++++++ .../standalone/common/truncate/truncate.sql | 13 ++++ 22 files changed, 344 insertions(+), 37 deletions(-) diff --git a/src/sql/src/parser.rs b/src/sql/src/parser.rs index e048384dc2..91e9b19162 100644 --- a/src/sql/src/parser.rs +++ b/src/sql/src/parser.rs @@ -13,6 +13,7 @@ // limitations under the License. use snafu::ResultExt; +use sqlparser::ast::Ident; use sqlparser::dialect::Dialect; use sqlparser::keywords::Keyword; use sqlparser::parser::{Parser, ParserError}; @@ -166,6 +167,29 @@ impl<'a> ParserContext<'a> { pub(crate) fn peek_token_as_string(&self) -> String { self.parser.peek_token().to_string() } + + /// Canonicalize the identifier to lowercase if it's not quoted. + pub fn canonicalize_identifier(ident: Ident) -> Ident { + if ident.quote_style.is_some() { + ident + } else { + Ident { + value: ident.value.to_lowercase(), + quote_style: None, + } + } + } + + /// Like [canonicalize_identifier] but for [ObjectName]. + pub fn canonicalize_object_name(object_name: ObjectName) -> ObjectName { + ObjectName( + object_name + .0 + .into_iter() + .map(Self::canonicalize_identifier) + .collect(), + ) + } } #[cfg(test)] diff --git a/src/sql/src/parsers/alter_parser.rs b/src/sql/src/parsers/alter_parser.rs index a5436d8f53..7f137d52c9 100644 --- a/src/sql/src/parsers/alter_parser.rs +++ b/src/sql/src/parsers/alter_parser.rs @@ -33,20 +33,22 @@ impl<'a> ParserContext<'a> { let parser = &mut self.parser; parser.expect_keywords(&[Keyword::ALTER, Keyword::TABLE])?; - let table_name = parser.parse_object_name()?; + let raw_table_name = parser.parse_object_name()?; + let table_name = Self::canonicalize_object_name(raw_table_name); let alter_operation = if parser.parse_keyword(Keyword::ADD) { if let Some(constraint) = parser.parse_optional_table_constraint()? { AlterTableOperation::AddConstraint(constraint) } else { let _ = parser.parse_keyword(Keyword::COLUMN); - let column_def = parser.parse_column_def()?; + let mut column_def = parser.parse_column_def()?; + column_def.name = Self::canonicalize_identifier(column_def.name); let location = if parser.parse_keyword(Keyword::FIRST) { Some(AddColumnLocation::First) } else if let Token::Word(word) = parser.peek_token().token { if word.value.to_ascii_uppercase() == "AFTER" { let _ = parser.next_token(); - let name = parser.parse_identifier()?; + let name = Self::canonicalize_identifier(parser.parse_identifier()?); Some(AddColumnLocation::After { column_name: name.value, }) @@ -63,7 +65,7 @@ impl<'a> ParserContext<'a> { } } else if parser.parse_keyword(Keyword::DROP) { if parser.parse_keyword(Keyword::COLUMN) { - let name = self.parser.parse_identifier()?; + let name = Self::canonicalize_identifier(self.parser.parse_identifier()?); AlterTableOperation::DropColumn { name } } else { return Err(ParserError::ParserError(format!( @@ -72,7 +74,8 @@ impl<'a> ParserContext<'a> { ))); } } else if parser.parse_keyword(Keyword::RENAME) { - let new_table_name_obj = parser.parse_object_name()?; + let new_table_name_obj_raw = parser.parse_object_name()?; + let new_table_name_obj = Self::canonicalize_object_name(new_table_name_obj_raw); let new_table_name = match &new_table_name_obj.0[..] { [table] => table.value.clone(), _ => { diff --git a/src/sql/src/parsers/copy_parser.rs b/src/sql/src/parsers/copy_parser.rs index 7b47c79783..17ee3df152 100644 --- a/src/sql/src/parsers/copy_parser.rs +++ b/src/sql/src/parsers/copy_parser.rs @@ -69,7 +69,7 @@ impl<'a> ParserContext<'a> { } fn parse_copy_table(&mut self) -> Result { - let table_name = + let raw_table_name = self.parser .parse_object_name() .with_context(|_| error::UnexpectedSnafu { @@ -77,6 +77,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_name = Self::canonicalize_object_name(raw_table_name); if self.parser.parse_keyword(Keyword::TO) { let (with, connection, location) = self.parse_copy_to()?; diff --git a/src/sql/src/parsers/create_parser.rs b/src/sql/src/parsers/create_parser.rs index 6d01f8bacc..d81c3eb6c4 100644 --- a/src/sql/src/parsers/create_parser.rs +++ b/src/sql/src/parsers/create_parser.rs @@ -73,7 +73,7 @@ impl<'a> ParserContext<'a> { let if_not_exists = self.parser .parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]); - let table_name = self + let raw_table_name = self .parser .parse_object_name() .context(error::UnexpectedSnafu { @@ -81,6 +81,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_name = Self::canonicalize_object_name(raw_table_name); let (columns, constraints) = self.parse_columns()?; let engine = self.parse_table_engine(common_catalog::consts::FILE_ENGINE)?; let options = self @@ -142,7 +143,7 @@ impl<'a> ParserContext<'a> { self.parser .parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]); - let table_name = self + let raw_table_name = self .parser .parse_object_name() .context(error::UnexpectedSnafu { @@ -150,6 +151,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_name = Self::canonicalize_object_name(raw_table_name); let (columns, constraints) = self.parse_columns()?; @@ -197,10 +199,14 @@ impl<'a> ParserContext<'a> { actual: self.peek_token_as_string(), })?; - let column_list = self + let raw_column_list = self .parser .parse_parenthesized_column_list(Mandatory, false) .context(error::SyntaxSnafu)?; + let column_list = raw_column_list + .into_iter() + .map(Self::canonicalize_identifier) + .collect(); let entries = self.parse_comma_separated(Self::parse_partition_entry)?; @@ -435,7 +441,7 @@ impl<'a> ParserContext<'a> { }; } Ok(ColumnDef { - name, + name: Self::canonicalize_identifier(name), data_type, collation, options, @@ -488,7 +494,8 @@ impl<'a> ParserContext<'a> { fn parse_optional_table_constraint(&mut self) -> Result> { let name = if self.parser.parse_keyword(Keyword::CONSTRAINT) { - Some(self.parser.parse_identifier().context(error::SyntaxSnafu)?) + let raw_name = self.parser.parse_identifier().context(error::SyntaxSnafu)?; + Some(Self::canonicalize_identifier(raw_name)) } else { None }; @@ -504,10 +511,14 @@ impl<'a> ParserContext<'a> { expected: "KEY", actual: self.peek_token_as_string(), })?; - let columns = self + let raw_columns = self .parser .parse_parenthesized_column_list(Mandatory, false) .context(error::SyntaxSnafu)?; + let columns = raw_columns + .into_iter() + .map(Self::canonicalize_identifier) + .collect(); Ok(Some(TableConstraint::Unique { name, columns, @@ -526,10 +537,14 @@ impl<'a> ParserContext<'a> { actual: self.peek_token_as_string(), })?; - let columns = self + let raw_columns = self .parser .parse_parenthesized_column_list(Mandatory, false) .context(error::SyntaxSnafu)?; + let columns = raw_columns + .into_iter() + .map(Self::canonicalize_identifier) + .collect::>(); ensure!( columns.len() == 1, diff --git a/src/sql/src/parsers/describe_parser.rs b/src/sql/src/parsers/describe_parser.rs index a7c6b5c21e..3348137f9d 100644 --- a/src/sql/src/parsers/describe_parser.rs +++ b/src/sql/src/parsers/describe_parser.rs @@ -30,7 +30,7 @@ impl<'a> ParserContext<'a> { } fn parse_describe_table(&mut self) -> Result { - let table_idents = + let raw_table_idents = self.parser .parse_object_name() .with_context(|_| error::UnexpectedSnafu { @@ -38,6 +38,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_idents = Self::canonicalize_object_name(raw_table_idents); ensure!( !table_idents.0.is_empty(), InvalidTableNameSnafu { diff --git a/src/sql/src/parsers/drop_parser.rs b/src/sql/src/parsers/drop_parser.rs index add3810385..92cddf7284 100644 --- a/src/sql/src/parsers/drop_parser.rs +++ b/src/sql/src/parsers/drop_parser.rs @@ -29,7 +29,7 @@ impl<'a> ParserContext<'a> { } let _ = self.parser.next_token(); - let table_ident = + let raw_table_ident = self.parser .parse_object_name() .with_context(|_| error::UnexpectedSnafu { @@ -37,6 +37,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_ident = Self::canonicalize_object_name(raw_table_ident); ensure!( !table_ident.0.is_empty(), InvalidTableNameSnafu { diff --git a/src/sql/src/parsers/show_parser.rs b/src/sql/src/parsers/show_parser.rs index 48a64e86ec..1278ea55bf 100644 --- a/src/sql/src/parsers/show_parser.rs +++ b/src/sql/src/parsers/show_parser.rs @@ -50,7 +50,7 @@ impl<'a> ParserContext<'a> { /// Parse SHOW CREATE TABLE statement fn parse_show_create_table(&mut self) -> Result { - let table_name = + let raw_table_name = self.parser .parse_object_name() .with_context(|_| error::UnexpectedSnafu { @@ -58,6 +58,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_name = Self::canonicalize_object_name(raw_table_name); ensure!( !table_name.0.is_empty(), InvalidTableNameSnafu { diff --git a/src/sql/src/parsers/truncate_parser.rs b/src/sql/src/parsers/truncate_parser.rs index e3a31f2db2..fa5253bcf0 100644 --- a/src/sql/src/parsers/truncate_parser.rs +++ b/src/sql/src/parsers/truncate_parser.rs @@ -26,7 +26,7 @@ impl<'a> ParserContext<'a> { let _ = self.parser.next_token(); let _ = self.parser.parse_keyword(Keyword::TABLE); - let table_ident = + let raw_table_ident = self.parser .parse_object_name() .with_context(|_| error::UnexpectedSnafu { @@ -34,6 +34,7 @@ impl<'a> ParserContext<'a> { expected: "a table name", actual: self.peek_token_as_string(), })?; + let table_ident = Self::canonicalize_object_name(raw_table_ident); ensure!( !table_ident.0.is_empty(), diff --git a/tests/cases/standalone/common/alter/add_col.result b/tests/cases/standalone/common/alter/add_col.result index 7b3c6d4fb4..c01420c641 100644 --- a/tests/cases/standalone/common/alter/add_col.result +++ b/tests/cases/standalone/common/alter/add_col.result @@ -87,6 +87,23 @@ DESC TABLE test; | idc | String | | YES | idc | FIELD | +--------+----------------------+-----+------+---------+---------------+ +ALTER TABLE test ADD COLUMN "IdC" STRING default 'idc' PRIMARY KEY; + +Affected Rows: 0 + +DESC TABLE test; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| i | Int32 | | YES | | FIELD | +| j | TimestampMillisecond | PRI | NO | | TIMESTAMP | +| k | Int32 | | YES | | FIELD | +| host | String | | YES | | FIELD | +| idc | String | | YES | idc | FIELD | +| IdC | String | | YES | idc | FIELD | ++--------+----------------------+-----+------+---------+---------------+ + DROP TABLE test; Affected Rows: 0 diff --git a/tests/cases/standalone/common/alter/add_col.sql b/tests/cases/standalone/common/alter/add_col.sql index 8d506959ef..7cd4159a48 100644 --- a/tests/cases/standalone/common/alter/add_col.sql +++ b/tests/cases/standalone/common/alter/add_col.sql @@ -22,4 +22,8 @@ SELECT * FROM test; DESC TABLE test; +ALTER TABLE test ADD COLUMN "IdC" STRING default 'idc' PRIMARY KEY; + +DESC TABLE test; + DROP TABLE test; diff --git a/tests/cases/standalone/common/alter/drop_col.result b/tests/cases/standalone/common/alter/drop_col.result index cf0c7251ef..81a9d46f06 100644 --- a/tests/cases/standalone/common/alter/drop_col.result +++ b/tests/cases/standalone/common/alter/drop_col.result @@ -6,7 +6,11 @@ INSERT INTO test VALUES (1, 1), (2, 2); Affected Rows: 2 -ALTER TABLE test DROP COLUMN i; +ALTER TABLE test DROP COLUMN "I"; + +Error: 4002(TableColumnNotFound), Column I not exists in table test + +ALTER TABLE test DROP COLUMN I; Affected Rows: 0 diff --git a/tests/cases/standalone/common/alter/drop_col.sql b/tests/cases/standalone/common/alter/drop_col.sql index 6bda827833..778613f036 100644 --- a/tests/cases/standalone/common/alter/drop_col.sql +++ b/tests/cases/standalone/common/alter/drop_col.sql @@ -2,7 +2,9 @@ CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX); INSERT INTO test VALUES (1, 1), (2, 2); -ALTER TABLE test DROP COLUMN i; +ALTER TABLE test DROP COLUMN "I"; + +ALTER TABLE test DROP COLUMN I; SELECT * FROM test; diff --git a/tests/cases/standalone/common/alter/rename_table.result b/tests/cases/standalone/common/alter/rename_table.result index 40982666dc..b635d89e25 100644 --- a/tests/cases/standalone/common/alter/rename_table.result +++ b/tests/cases/standalone/common/alter/rename_table.result @@ -81,3 +81,46 @@ DROP TABLE new_table; Affected Rows: 0 +CREATE TABLE "AbCdE"("CoLa" INTEGER, "cOlB" TIMESTAMP TIME INDEX); + +Affected Rows: 0 + +ALTER TABLE "AbCdE" RENAME "fGhI"; + +Affected Rows: 0 + +DESC TABLE "fGhI"; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| CoLa | Int32 | | YES | | FIELD | +| cOlB | TimestampMillisecond | PRI | NO | | TIMESTAMP | ++--------+----------------------+-----+------+---------+---------------+ + +SELECT * FROM "fGhI"; + +++ +++ + +ALTER TABLE "fGhI" RENAME JkLmN; + +Affected Rows: 0 + +DESC TABLE "JkLmN"; + +Error: 4001(TableNotFound), Table not found: JkLmN + +DESC TABLE JkLmN; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| CoLa | Int32 | | YES | | FIELD | +| cOlB | TimestampMillisecond | PRI | NO | | TIMESTAMP | ++--------+----------------------+-----+------+---------+---------------+ + +DROP TABLE jklmn; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/common/alter/rename_table.sql b/tests/cases/standalone/common/alter/rename_table.sql index 85c3e8b4b9..377161166b 100644 --- a/tests/cases/standalone/common/alter/rename_table.sql +++ b/tests/cases/standalone/common/alter/rename_table.sql @@ -28,3 +28,20 @@ ALTER TABLE new_table RENAME t; DROP TABLE t; DROP TABLE new_table; + + +CREATE TABLE "AbCdE"("CoLa" INTEGER, "cOlB" TIMESTAMP TIME INDEX); + +ALTER TABLE "AbCdE" RENAME "fGhI"; + +DESC TABLE "fGhI"; + +SELECT * FROM "fGhI"; + +ALTER TABLE "fGhI" RENAME JkLmN; + +DESC TABLE "JkLmN"; + +DESC TABLE JkLmN; + +DROP TABLE jklmn; diff --git a/tests/cases/standalone/common/create/upper_case_table_name.result b/tests/cases/standalone/common/create/upper_case_table_name.result index c2957f0496..39562efac4 100644 --- a/tests/cases/standalone/common/create/upper_case_table_name.result +++ b/tests/cases/standalone/common/create/upper_case_table_name.result @@ -6,11 +6,11 @@ use upper_case_table_name; Affected Rows: 0 -create table system_Metric(ts timestamp time index); +create table "system_Metric"(ts timestamp time index); Affected Rows: 0 -insert into system_Metric values (0), (1); +insert into "system_Metric" values (0), (1); Affected Rows: 2 @@ -27,7 +27,76 @@ select * from "system_Metric"; | 1970-01-01T00:00:00.001 | +-------------------------+ -drop table system_Metric; +drop table "system_Metric"; + +Affected Rows: 0 + +create table "AbCdEfG"("CoLA" string, "cOlB" string, "tS" timestamp time index, primary key ("CoLA")); + +Affected Rows: 0 + +desc table "AbCdEfG"; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| CoLA | String | PRI | YES | | TAG | +| cOlB | String | | YES | | FIELD | +| tS | TimestampMillisecond | PRI | NO | | TIMESTAMP | ++--------+----------------------+-----+------+---------+---------------+ + +-- unquoted table name and column name. +create table AbCdEfGe(CoLA string, cOlB string, tS timestamp time index, primary key (cOlA)); + +Affected Rows: 0 + +desc table aBcDeFgE; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| cola | String | PRI | YES | | TAG | +| colb | String | | YES | | FIELD | +| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP | ++--------+----------------------+-----+------+---------+---------------+ + +drop table "AbCdEfG"; + +Affected Rows: 0 + +drop table aBcDeFgE; + +Affected Rows: 0 + +-- unquoted column name in partition +create table AbCdEfGe( + CoLA string PRIMARY KEY, + tS timestamp time index +) PARTITION BY RANGE COLUMNS (cOlA) ( + PARTITION p0 VALUES LESS THAN (MAXVALUE) +); + +Affected Rows: 0 + +drop table abcdefge; + +Affected Rows: 0 + +-- unquoted column name in TIME INDEX +create table AbCdEfGe(CoLA string, tS timestamp, TIME INDEX (Ts)); + +Affected Rows: 0 + +desc table abcdefge; + ++--------+----------------------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++--------+----------------------+-----+------+---------+---------------+ +| cola | String | | YES | | FIELD | +| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP | ++--------+----------------------+-----+------+---------+---------------+ + +drop table abcdefge; Affected Rows: 0 diff --git a/tests/cases/standalone/common/create/upper_case_table_name.sql b/tests/cases/standalone/common/create/upper_case_table_name.sql index 32bb1fc3b3..90cedca005 100644 --- a/tests/cases/standalone/common/create/upper_case_table_name.sql +++ b/tests/cases/standalone/common/create/upper_case_table_name.sql @@ -2,14 +2,44 @@ create database upper_case_table_name; use upper_case_table_name; -create table system_Metric(ts timestamp time index); +create table "system_Metric"(ts timestamp time index); -insert into system_Metric values (0), (1); +insert into "system_Metric" values (0), (1); select * from system_Metric; select * from "system_Metric"; -drop table system_Metric; +drop table "system_Metric"; + +create table "AbCdEfG"("CoLA" string, "cOlB" string, "tS" timestamp time index, primary key ("CoLA")); + +desc table "AbCdEfG"; + +-- unquoted table name and column name. +create table AbCdEfGe(CoLA string, cOlB string, tS timestamp time index, primary key (cOlA)); + +desc table aBcDeFgE; + +drop table "AbCdEfG"; + +drop table aBcDeFgE; + +-- unquoted column name in partition +create table AbCdEfGe( + CoLA string PRIMARY KEY, + tS timestamp time index +) PARTITION BY RANGE COLUMNS (cOlA) ( + PARTITION p0 VALUES LESS THAN (MAXVALUE) +); + +drop table abcdefge; + +-- unquoted column name in TIME INDEX +create table AbCdEfGe(CoLA string, tS timestamp, TIME INDEX (Ts)); + +desc table abcdefge; + +drop table abcdefge; use public; diff --git a/tests/cases/standalone/common/delete/delete.result b/tests/cases/standalone/common/delete/delete.result index 7885c4b0cf..4df80c05a2 100644 --- a/tests/cases/standalone/common/delete/delete.result +++ b/tests/cases/standalone/common/delete/delete.result @@ -60,3 +60,27 @@ DROP TABLE monitor; Affected Rows: 0 +CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0); + +Affected Rows: 0 + +DELETE FROM "MoNiToR" WHERE "hOsT" = 'host2'; + +Affected Rows: 0 + +DROP TABLE "MoNiToR"; + +Affected Rows: 0 + +CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0); + +Affected Rows: 0 + +DELETE FROM MoNiToR WHERE hOsT = 'host2'; + +Affected Rows: 0 + +DROP TABLE MoNiToR; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/common/delete/delete.sql b/tests/cases/standalone/common/delete/delete.sql index f59eb73df8..9786aa2d7b 100644 --- a/tests/cases/standalone/common/delete/delete.sql +++ b/tests/cases/standalone/common/delete/delete.sql @@ -24,3 +24,16 @@ DELETE FROM monitor WHERE memory > 2048; SELECT ts, host, cpu, memory FROM monitor ORDER BY ts; DROP TABLE monitor; + + +CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0); + +DELETE FROM "MoNiToR" WHERE "hOsT" = 'host2'; + +DROP TABLE "MoNiToR"; + +CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0); + +DELETE FROM MoNiToR WHERE hOsT = 'host2'; + +DROP TABLE MoNiToR; diff --git a/tests/cases/standalone/common/order/order_variable_size_payload.result b/tests/cases/standalone/common/order/order_variable_size_payload.result index becf9aa5c1..050026cea7 100644 --- a/tests/cases/standalone/common/order/order_variable_size_payload.result +++ b/tests/cases/standalone/common/order/order_variable_size_payload.result @@ -347,19 +347,19 @@ select i, split_part(s, 'b', 1) from test8 order by i; | | d | +---+----------------------------------------+ -CREATE TABLE DirectReports +CREATE TABLE "DirectReports" ( - EmployeeID smallint, + "EmployeeID" smallint, "Name" varchar NOT NULL, - Title varchar NOT NULL, - EmployeeLevel int NOT NULL, + "Title" varchar NOT NULL, + "EmployeeLevel" int NOT NULL, "Sort" varchar NOT NULL, "Timestamp" TIMESTAMP TIME INDEX, ); Affected Rows: 0 -INSERT INTO DirectReports VALUES +INSERT INTO "DirectReports" VALUES (1, 'Ken Sánchez', 'Chief Executive Officer', 1, 'Ken Sánchez', 1), (273, '>Brian Welcker', 'Vice President of Sales', 2, 'Ken Sánchez>Brian Welcker', 2), (274, '>>Stephen Jiang', 'North American Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Stephen Jiang', 3), @@ -426,7 +426,7 @@ DROP table test8; Affected Rows: 0 -DROP TABLE DirectReports; +DROP TABLE "DirectReports"; Affected Rows: 0 diff --git a/tests/cases/standalone/common/order/order_variable_size_payload.sql b/tests/cases/standalone/common/order/order_variable_size_payload.sql index b71ba7405e..0fbf6a067e 100644 --- a/tests/cases/standalone/common/order/order_variable_size_payload.sql +++ b/tests/cases/standalone/common/order/order_variable_size_payload.sql @@ -82,17 +82,17 @@ insert into test8 values (3, 'aba', 1), (1, 'ccbcc', 2), (NULL, 'dbdbd', 3), (2, select i, split_part(s, 'b', 1) from test8 order by i; -CREATE TABLE DirectReports +CREATE TABLE "DirectReports" ( - EmployeeID smallint, + "EmployeeID" smallint, "Name" varchar NOT NULL, - Title varchar NOT NULL, - EmployeeLevel int NOT NULL, + "Title" varchar NOT NULL, + "EmployeeLevel" int NOT NULL, "Sort" varchar NOT NULL, "Timestamp" TIMESTAMP TIME INDEX, ); -INSERT INTO DirectReports VALUES +INSERT INTO "DirectReports" VALUES (1, 'Ken Sánchez', 'Chief Executive Officer', 1, 'Ken Sánchez', 1), (273, '>Brian Welcker', 'Vice President of Sales', 2, 'Ken Sánchez>Brian Welcker', 2), (274, '>>Stephen Jiang', 'North American Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Stephen Jiang', 3), @@ -125,4 +125,4 @@ DROP table test7; DROP table test8; -DROP TABLE DirectReports; +DROP TABLE "DirectReports"; diff --git a/tests/cases/standalone/common/truncate/truncate.result b/tests/cases/standalone/common/truncate/truncate.result index 42358d542a..c0e7560f81 100644 --- a/tests/cases/standalone/common/truncate/truncate.result +++ b/tests/cases/standalone/common/truncate/truncate.result @@ -74,3 +74,27 @@ DROP TABLE monitor; Affected Rows: 0 +CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0); + +Affected Rows: 0 + +TRUNCATE "MoNiToR"; + +Affected Rows: 0 + +DROP TABLE "MoNiToR"; + +Affected Rows: 0 + +CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0); + +Affected Rows: 0 + +TRUNCATE MoNiToR; + +Affected Rows: 0 + +DROP TABLE MoNiToR; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/common/truncate/truncate.sql b/tests/cases/standalone/common/truncate/truncate.sql index b5fd249857..66cfd813cc 100644 --- a/tests/cases/standalone/common/truncate/truncate.sql +++ b/tests/cases/standalone/common/truncate/truncate.sql @@ -31,3 +31,16 @@ TRUNCATE monitor; SELECT ts, host, cpu, memory FROM monitor ORDER BY ts; DROP TABLE monitor; + + +CREATE TABLE "MoNiToR" ("hOsT" STRING PRIMARY KEY, "tS" TIMESTAMP TIME INDEX, "cPu" DOUBLE DEFAULT 0); + +TRUNCATE "MoNiToR"; + +DROP TABLE "MoNiToR"; + +CREATE TABLE MoNiToR (hOsT STRING PRIMARY KEY, tS TIMESTAMP TIME INDEX, cPu DOUBLE DEFAULT 0); + +TRUNCATE MoNiToR; + +DROP TABLE MoNiToR;