mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-23 00:10:38 +00:00
chore: deny unused results (#1825)
* chore: deny unused results * rebase
This commit is contained in:
@@ -82,24 +82,24 @@ impl<'a> ParserContext<'a> {
|
||||
Token::Word(w) => {
|
||||
match w.keyword {
|
||||
Keyword::CREATE => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_create()
|
||||
}
|
||||
|
||||
Keyword::EXPLAIN => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_explain()
|
||||
}
|
||||
|
||||
Keyword::SHOW => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_show()
|
||||
}
|
||||
|
||||
Keyword::DELETE => self.parse_delete(),
|
||||
|
||||
Keyword::DESCRIBE | Keyword::DESC => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_describe()
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl<'a> ParserContext<'a> {
|
||||
Keyword::DROP => self.parse_drop(),
|
||||
|
||||
Keyword::USE => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
let database_name =
|
||||
self.parser
|
||||
@@ -157,7 +157,7 @@ impl<'a> ParserContext<'a> {
|
||||
if self.consume_token("DATABASES") || self.consume_token("SCHEMAS") {
|
||||
self.parse_show_databases()
|
||||
} else if self.matches_keyword(Keyword::TABLES) {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_show_tables()
|
||||
} else if self.consume_token("CREATE") {
|
||||
if self.consume_token("TABLE") {
|
||||
@@ -201,7 +201,7 @@ impl<'a> ParserContext<'a> {
|
||||
// SHOW TABLES [in | FROM] [DATABASE]
|
||||
Token::Word(w) => match w.keyword {
|
||||
Keyword::IN | Keyword::FROM => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let db_name = self.parser.parse_object_name().with_context(|_| {
|
||||
error::UnexpectedSnafu {
|
||||
sql: self.sql,
|
||||
@@ -230,7 +230,7 @@ impl<'a> ParserContext<'a> {
|
||||
// SHOW TABLES [WHERE | LIKE] [EXPR]
|
||||
Token::Word(w) => match w.keyword {
|
||||
Keyword::LIKE => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
ShowKind::Like(self.parser.parse_identifier().with_context(|_| {
|
||||
error::UnexpectedSnafu {
|
||||
sql: self.sql,
|
||||
@@ -240,7 +240,7 @@ impl<'a> ParserContext<'a> {
|
||||
})?)
|
||||
}
|
||||
Keyword::WHERE => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
ShowKind::Where(self.parser.parse_expr().with_context(|_| {
|
||||
error::UnexpectedSnafu {
|
||||
sql: self.sql,
|
||||
@@ -260,7 +260,7 @@ impl<'a> ParserContext<'a> {
|
||||
/// Parses DESCRIBE statements
|
||||
fn parse_describe(&mut self) -> Result<Statement> {
|
||||
if self.matches_keyword(Keyword::TABLE) {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_describe_table()
|
||||
} else {
|
||||
self.unsupported(self.peek_token_as_string())
|
||||
@@ -299,11 +299,11 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
fn parse_drop(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
if !self.matches_keyword(Keyword::TABLE) {
|
||||
return self.unsupported(self.peek_token_as_string());
|
||||
}
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
let table_ident =
|
||||
self.parser
|
||||
@@ -340,7 +340,7 @@ impl<'a> ParserContext<'a> {
|
||||
|
||||
pub fn consume_token(&mut self, expected: &str) -> bool {
|
||||
if self.peek_token_as_string().to_uppercase() == *expected.to_uppercase() {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
@@ -47,7 +47,7 @@ impl<'a> ParserContext<'a> {
|
||||
Some(AddColumnLocation::First)
|
||||
} else if let Token::Word(word) = parser.peek_token().token {
|
||||
if word.value.to_ascii_uppercase() == "AFTER" {
|
||||
parser.next_token();
|
||||
let _ = parser.next_token();
|
||||
let name = parser.parse_identifier()?;
|
||||
Some(AddColumnLocation::After {
|
||||
column_name: name.value,
|
||||
|
||||
@@ -31,10 +31,10 @@ pub type Connection = HashMap<String, String>;
|
||||
// COPY tbl TO 'output.parquet';
|
||||
impl<'a> ParserContext<'a> {
|
||||
pub(crate) fn parse_copy(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let next = self.parser.peek_token();
|
||||
let copy = if let Word(word) = next.token && word.keyword == Keyword::DATABASE {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let copy_database = self.parser_copy_database()?;
|
||||
crate::statements::copy::Copy::CopyDatabase(copy_database)
|
||||
} else {
|
||||
|
||||
@@ -61,7 +61,7 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
fn parse_create_external_table(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parser
|
||||
.expect_keyword(Keyword::TABLE)
|
||||
.context(error::SyntaxSnafu { sql: self.sql })?;
|
||||
@@ -103,7 +103,7 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
fn parse_create_database(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
let if_not_exists =
|
||||
self.parser
|
||||
@@ -125,7 +125,7 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
fn parse_create_table(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let if_not_exists =
|
||||
self.parser
|
||||
.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
|
||||
@@ -377,7 +377,7 @@ impl<'a> ParserContext<'a> {
|
||||
column.options.push(not_null_opt);
|
||||
}
|
||||
|
||||
column.options.remove(index);
|
||||
let _ = column.options.remove(index);
|
||||
}
|
||||
|
||||
columns.push(column);
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::statements::statement::Statement;
|
||||
/// DELETE statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
pub(crate) fn parse_delete(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let spstatement = self
|
||||
.parser
|
||||
.parse_delete()
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::statements::statement::Statement;
|
||||
/// INSERT statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
pub(crate) fn parse_insert(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
let spstatement = self
|
||||
.parser
|
||||
.parse_insert()
|
||||
|
||||
@@ -34,7 +34,7 @@ use sqlparser::parser::Parser;
|
||||
/// - TQL ANALYZE <query>
|
||||
impl<'a> ParserContext<'a> {
|
||||
pub(crate) fn parse_tql(&mut self) -> Result<Statement> {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
match self.parser.peek_token().token {
|
||||
Token::Word(w) => {
|
||||
@@ -44,18 +44,18 @@ impl<'a> ParserContext<'a> {
|
||||
if (uppercase == EVAL || uppercase == EVALUATE)
|
||||
&& w.quote_style.is_none() =>
|
||||
{
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_tql_eval()
|
||||
.context(error::SyntaxSnafu { sql: self.sql })
|
||||
}
|
||||
|
||||
Keyword::EXPLAIN => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_tql_explain()
|
||||
}
|
||||
|
||||
Keyword::ANALYZE => {
|
||||
self.parser.next_token();
|
||||
let _ = self.parser.next_token();
|
||||
self.parse_tql_analyze()
|
||||
.context(error::SyntaxSnafu { sql: self.sql })
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ pub fn column_def_to_schema(column_def: &ColumnDef, is_time_index: bool) -> Resu
|
||||
None
|
||||
}
|
||||
}) {
|
||||
column_schema
|
||||
let _ = column_schema
|
||||
.mut_metadata()
|
||||
.insert(COMMENT_KEY.to_string(), c.to_string());
|
||||
}
|
||||
|
||||
@@ -93,6 +93,6 @@ mod tests {
|
||||
#[test]
|
||||
pub fn test_describe_missing_table_name() {
|
||||
let sql = "DESCRIBE TABLE";
|
||||
ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).unwrap_err();
|
||||
assert!(ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,6 @@ mod tests {
|
||||
#[test]
|
||||
pub fn test_show_create_missing_table_name() {
|
||||
let sql = "SHOW CREATE TABLE";
|
||||
ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).unwrap_err();
|
||||
assert!(ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn to_lowercase_options_map(opts: &[SqlOption]) -> HashMap<String, String> {
|
||||
Value::SingleQuotedString(s) | Value::DoubleQuotedString(s) => s.clone(),
|
||||
_ => value.to_string(),
|
||||
};
|
||||
map.insert(name.value.to_lowercase().clone(), value_str);
|
||||
let _ = map.insert(name.value.to_lowercase().clone(), value_str);
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user