mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-28 10:50:39 +00:00
chore: udapte Rust toolchain to 2024-10-19 (#4857)
* update rust toolchain * change toolchain to 2024-10-17 * fix: clippy * fix: ut * bump shadow-rs * fix: use nightly-2024-10-19 * fix: clippy * chore/udapte-toolchain-2024-10-17: Update DEV_BUILDER_IMAGE_TAG to 2024-10-19-a5c00e85-20241024184445 in Makefile
This commit is contained in:
@@ -37,9 +37,9 @@ pub struct ParserContext<'a> {
|
||||
pub(crate) sql: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Construct a new ParserContext.
|
||||
pub fn new(dialect: &'a dyn Dialect, sql: &'a str) -> Result<ParserContext<'a>> {
|
||||
pub fn new<'a>(dialect: &'a dyn Dialect, sql: &'a str) -> Result<ParserContext<'a>> {
|
||||
let parser = Parser::new(dialect)
|
||||
.with_options(ParserOptions::new().with_trailing_commas(true))
|
||||
.try_with_sql(sql)
|
||||
@@ -55,7 +55,7 @@ impl<'a> ParserContext<'a> {
|
||||
|
||||
/// Parses SQL with given dialect
|
||||
pub fn create_with_dialect(
|
||||
sql: &'a str,
|
||||
sql: &str,
|
||||
dialect: &dyn Dialect,
|
||||
_opts: ParseOptions,
|
||||
) -> Result<Vec<Statement>> {
|
||||
@@ -87,7 +87,7 @@ impl<'a> ParserContext<'a> {
|
||||
Ok(stmts)
|
||||
}
|
||||
|
||||
pub fn parse_table_name(sql: &'a str, dialect: &dyn Dialect) -> Result<ObjectName> {
|
||||
pub fn parse_table_name(sql: &str, dialect: &dyn Dialect) -> Result<ObjectName> {
|
||||
let parser = Parser::new(dialect)
|
||||
.with_options(ParserOptions::new().with_trailing_commas(true))
|
||||
.try_with_sql(sql)
|
||||
@@ -106,7 +106,7 @@ impl<'a> ParserContext<'a> {
|
||||
Ok(Self::canonicalize_object_name(raw_table_name))
|
||||
}
|
||||
|
||||
pub fn parse_function(sql: &'a str, dialect: &dyn Dialect) -> Result<Expr> {
|
||||
pub fn parse_function(sql: &str, dialect: &dyn Dialect) -> Result<Expr> {
|
||||
let mut parser = Parser::new(dialect)
|
||||
.with_options(ParserOptions::new().with_trailing_commas(true))
|
||||
.try_with_sql(sql)
|
||||
@@ -191,23 +191,20 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
/// Parses MySQL style 'PREPARE stmt_name FROM stmt' into a (stmt_name, stmt) tuple.
|
||||
pub fn parse_mysql_prepare_stmt(
|
||||
sql: &'a str,
|
||||
dialect: &dyn Dialect,
|
||||
) -> Result<(String, String)> {
|
||||
pub fn parse_mysql_prepare_stmt(sql: &str, dialect: &dyn Dialect) -> Result<(String, String)> {
|
||||
ParserContext::new(dialect, sql)?.parse_mysql_prepare()
|
||||
}
|
||||
|
||||
/// Parses MySQL style 'EXECUTE stmt_name USING param_list' into a stmt_name string and a list of parameters.
|
||||
pub fn parse_mysql_execute_stmt(
|
||||
sql: &'a str,
|
||||
sql: &str,
|
||||
dialect: &dyn Dialect,
|
||||
) -> Result<(String, Vec<Expr>)> {
|
||||
ParserContext::new(dialect, sql)?.parse_mysql_execute()
|
||||
}
|
||||
|
||||
/// Parses MySQL style 'DEALLOCATE stmt_name' into a stmt_name string.
|
||||
pub fn parse_mysql_deallocate_stmt(sql: &'a str, dialect: &dyn Dialect) -> Result<String> {
|
||||
pub fn parse_mysql_deallocate_stmt(sql: &str, dialect: &dyn Dialect) -> Result<String> {
|
||||
ParserContext::new(dialect, sql)?.parse_deallocate()
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::statements::statement::Statement;
|
||||
|
||||
/// `admin` extension parser: `admin function(arg1, arg2, ...)`
|
||||
/// or `admin function`
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parse `admin function(arg1, arg2, ...)` or `admin function` statement
|
||||
pub(crate) fn parse_admin_command(&mut self) -> Result<Statement> {
|
||||
let _token = self.parser.next_token();
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::parser::ParserContext;
|
||||
use crate::statements::alter::{AlterTable, AlterTableOperation};
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_alter(&mut self) -> Result<Statement> {
|
||||
let alter_table = self.parse_alter_table().context(error::SyntaxSnafu)?;
|
||||
Ok(Statement::Alter(alter_table))
|
||||
@@ -46,7 +46,7 @@ impl<'a> ParserContext<'a> {
|
||||
let location = if self.parser.parse_keyword(Keyword::FIRST) {
|
||||
Some(AddColumnLocation::First)
|
||||
} else if let Token::Word(word) = self.parser.peek_token().token {
|
||||
if word.value.to_ascii_uppercase() == "AFTER" {
|
||||
if word.value.eq_ignore_ascii_case("AFTER") {
|
||||
let _ = self.parser.next_token();
|
||||
let name = Self::canonicalize_identifier(self.parse_identifier()?);
|
||||
Some(AddColumnLocation::After {
|
||||
|
||||
@@ -28,7 +28,7 @@ pub type With = HashMap<String, String>;
|
||||
pub type Connection = HashMap<String, String>;
|
||||
|
||||
// COPY tbl TO 'output.parquet';
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_copy(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
let next = self.parser.peek_token();
|
||||
|
||||
@@ -630,7 +630,7 @@ impl<'a> ParserContext<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_optional_column_option(parser: &mut Parser<'a>) -> Result<Option<ColumnOption>> {
|
||||
fn parse_optional_column_option(parser: &mut Parser<'_>) -> Result<Option<ColumnOption>> {
|
||||
if parser.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) {
|
||||
Ok(Some(ColumnOption::CharacterSet(
|
||||
parser.parse_object_name(false).context(SyntaxSnafu)?,
|
||||
@@ -681,7 +681,7 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
|
||||
fn parse_column_extensions(
|
||||
parser: &mut Parser<'a>,
|
||||
parser: &mut Parser<'_>,
|
||||
column_name: &Ident,
|
||||
column_type: &DataType,
|
||||
column_extensions: &mut ColumnExtensions,
|
||||
|
||||
@@ -18,7 +18,7 @@ use sqlparser::keywords::Keyword;
|
||||
use crate::error::{Result, SyntaxSnafu};
|
||||
use crate::parser::ParserContext;
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parses MySQL style 'PREPARE stmt_name' into a stmt_name string.
|
||||
pub(crate) fn parse_deallocate(&mut self) -> Result<String> {
|
||||
self.parser
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::statements::delete::Delete;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// DELETE statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_delete(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
let spstatement = self.parser.parse_delete().context(error::SyntaxSnafu)?;
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::statements::describe::DescribeTable;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// DESCRIBE statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_describe(&mut self) -> Result<Statement> {
|
||||
if self.matches_keyword(Keyword::TABLE) {
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::statements::drop::{DropDatabase, DropFlow, DropTable, DropView};
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// DROP statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_drop(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
match self.parser.peek_token().token {
|
||||
|
||||
@@ -20,7 +20,7 @@ use sqlparser::parser::Parser;
|
||||
use crate::error::{Result, SyntaxSnafu};
|
||||
use crate::parser::ParserContext;
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parses MySQL style 'EXECUTE stmt_name USING param_list' into a stmt_name string and a list of parameters.
|
||||
/// Only use for MySQL. for PostgreSQL, use `sqlparser::parser::Parser::parse_execute` instead.
|
||||
pub(crate) fn parse_mysql_execute(&mut self) -> Result<(String, Vec<Expr>)> {
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::statements::explain::Explain;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// EXPLAIN statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_explain(&mut self) -> Result<Statement> {
|
||||
let explain_statement = self
|
||||
.parser
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::statements::insert::Insert;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// INSERT statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_insert(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
let spstatement = self.parser.parse_insert().context(error::SyntaxSnafu)?;
|
||||
|
||||
@@ -19,7 +19,7 @@ use sqlparser::tokenizer::Token;
|
||||
use crate::error::{Result, SyntaxSnafu};
|
||||
use crate::parser::ParserContext;
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parses MySQL style 'PREPARE stmt_name FROM stmt' into a (stmt_name, stmt) tuple.
|
||||
/// Only use for MySQL. for PostgreSQL, use `sqlparser::parser::Parser::parse_prepare` instead.
|
||||
pub(crate) fn parse_mysql_prepare(&mut self) -> Result<(String, String)> {
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::parser::ParserContext;
|
||||
use crate::statements::query::Query;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parses select and it's variants.
|
||||
pub(crate) fn parse_query(&mut self) -> Result<Statement> {
|
||||
let spquery = self.parser.parse_query().context(error::SyntaxSnafu)?;
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::statements::set_variables::SetVariables;
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// SET variables statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_set_variables(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
let spstatement = self.parser.parse_set().context(error::SyntaxSnafu)?;
|
||||
|
||||
@@ -28,7 +28,7 @@ use crate::statements::show::{
|
||||
use crate::statements::statement::Statement;
|
||||
|
||||
/// SHOW statement parser implementation
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
/// Parses SHOW statements
|
||||
/// todo(hl) support `show settings`/`show create`/`show users` etc.
|
||||
pub(crate) fn parse_show(&mut self) -> Result<Statement> {
|
||||
|
||||
@@ -39,7 +39,7 @@ use crate::parsers::error::{EvaluationSnafu, ParserSnafu, TQLError};
|
||||
/// - `TQL EVAL <query>`
|
||||
/// - `TQL EXPLAIN [VERBOSE] <query>`
|
||||
/// - `TQL ANALYZE [VERBOSE] <query>`
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_tql(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::statements::statement::Statement;
|
||||
use crate::statements::truncate::TruncateTable;
|
||||
|
||||
/// `TRUNCATE [TABLE] table_name;`
|
||||
impl<'a> ParserContext<'a> {
|
||||
impl ParserContext<'_> {
|
||||
pub(crate) fn parse_truncate(&mut self) -> Result<Statement> {
|
||||
let _ = self.parser.next_token();
|
||||
let _ = self.parser.parse_keyword(Keyword::TABLE);
|
||||
|
||||
@@ -131,6 +131,7 @@ impl Display for TqlAnalyze {
|
||||
}
|
||||
|
||||
/// Intermediate structure used to unify parameter mappings for various TQL operations.
|
||||
///
|
||||
/// This struct serves as a common parameter container for parsing TQL queries
|
||||
/// and constructing corresponding TQL operations: `TqlEval`, `TqlAnalyze` or `TqlExplain`.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn format_raw_object_name(name: &ObjectName) -> String {
|
||||
name: &'a ObjectName,
|
||||
}
|
||||
|
||||
impl<'a> Display for Inner<'a> {
|
||||
impl Display for Inner<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let mut delim = "";
|
||||
for ident in self.name.0.iter() {
|
||||
|
||||
Reference in New Issue
Block a user