Skip to content

Commit

Permalink
Support connection id is number
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed May 16, 2022
1 parent 64bfd22 commit b32a663
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions query/src/sql/parsers/parser_kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// Borrow from apache/arrow/rust/datafusion/src/sql/sql_parser
// See notice.md

use sqlparser::ast::Ident;
use sqlparser::parser::ParserError;
use sqlparser::tokenizer::Token;

use crate::sql::statements::DfKillStatement;
use crate::sql::DfParser;
Expand All @@ -34,9 +36,23 @@ impl<'a> DfParser<'a> {

// Parse 'KILL statement'.
fn parse_kill<const KILL_QUERY: bool>(&mut self) -> Result<DfStatement<'a>, ParserError> {
Ok(DfStatement::KillStatement(DfKillStatement {
object_id: self.parser.parse_identifier()?,
kill_query: KILL_QUERY,
}))
let token = self.parser.next_token();
match &token {
Token::Word(w) => Ok(DfStatement::KillStatement(DfKillStatement {
object_id: w.to_ident(),
kill_query: KILL_QUERY,
})),
Token::SingleQuotedString(s) | Token::Number(s, _) => {
Ok(DfStatement::KillStatement(DfKillStatement {
object_id: Ident::with_quote('\'', s),
kill_query: KILL_QUERY,
}))
}
Token::BackQuotedString(s) => Ok(DfStatement::KillStatement(DfKillStatement {
object_id: Ident::with_quote('`', s),
kill_query: KILL_QUERY,
})),
_ => self.expected("identifier", token),
}
}
}

0 comments on commit b32a663

Please sign in to comment.