Support use of BY NAME quantifier across all set ops (#1309)

Co-authored-by: Alexander Beedie <alexander.beedie@adia.ae>
Co-authored-by: Joey Hain <joey@sigmacomputing.com>
This commit is contained in:
Alexander Beedie 2024-06-17 22:14:40 +04:00 committed by GitHub
parent deac269710
commit 0330f9def5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 21 deletions

View file

@ -168,7 +168,7 @@ pub enum DataType {
UnsignedInt(Option<u64>),
/// Unsigned int4 with optional display width e.g. INT4 UNSIGNED or INT4(11) UNSIGNED
UnsignedInt4(Option<u64>),
/// Unsigned integer with optional display width e.g. INTGER UNSIGNED or INTEGER(11) UNSIGNED
/// Unsigned integer with optional display width e.g. INTEGER UNSIGNED or INTEGER(11) UNSIGNED
UnsignedInteger(Option<u64>),
/// Unsigned integer type in [clickhouse]
/// Note: UInt8 mean 8 bits in [clickhouse]
@ -699,7 +699,7 @@ pub enum CharacterLength {
/// Optional unit. If not informed, the ANSI handles it as CHARACTERS implicitly
unit: Option<CharLengthUnits>,
},
/// VARCHAR(MAX) or NVARCHAR(MAX), used in T-SQL (Miscrosoft SQL Server)
/// VARCHAR(MAX) or NVARCHAR(MAX), used in T-SQL (Microsoft SQL Server)
Max,
}

View file

@ -2265,7 +2265,7 @@ pub enum Statement {
/// SET [ SESSION | LOCAL ] ROLE role_name
/// ```
///
/// Sets sesssion state. Examples: [ANSI][1], [Postgresql][2], [MySQL][3], and [Oracle][4]
/// Sets session state. Examples: [ANSI][1], [Postgresql][2], [MySQL][3], and [Oracle][4]
///
/// [1]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#set-role-statement
/// [2]: https://www.postgresql.org/docs/14/sql-set-role.html
@ -2283,7 +2283,7 @@ pub enum Statement {
/// ```
///
/// Note: this is not a standard SQL statement, but it is supported by at
/// least MySQL and PostgreSQL. Not all MySQL-specific syntatic forms are
/// least MySQL and PostgreSQL. Not all MySQL-specific syntactic forms are
/// supported yet.
SetVariable {
local: bool,
@ -4750,7 +4750,7 @@ impl fmt::Display for FunctionArguments {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct FunctionArgumentList {
/// `[ ALL | DISTINCT ]
/// `[ ALL | DISTINCT ]`
pub duplicate_treatment: Option<DuplicateTreatment>,
/// The function arguments.
pub args: Vec<FunctionArg>,

View file

@ -8138,7 +8138,7 @@ impl<'a> Parser<'a> {
pub fn parse_set_quantifier(&mut self, op: &Option<SetOperator>) -> SetQuantifier {
match op {
Some(SetOperator::Union) => {
Some(SetOperator::Except | SetOperator::Intersect | SetOperator::Union) => {
if self.parse_keywords(&[Keyword::DISTINCT, Keyword::BY, Keyword::NAME]) {
SetQuantifier::DistinctByName
} else if self.parse_keywords(&[Keyword::BY, Keyword::NAME]) {
@ -8155,15 +8155,6 @@ impl<'a> Parser<'a> {
SetQuantifier::None
}
}
Some(SetOperator::Except) | Some(SetOperator::Intersect) => {
if self.parse_keyword(Keyword::ALL) {
SetQuantifier::All
} else if self.parse_keyword(Keyword::DISTINCT) {
SetQuantifier::Distinct
} else {
SetQuantifier::None
}
}
_ => SetQuantifier::None,
}
}
@ -8547,10 +8538,10 @@ impl<'a> Parser<'a> {
})
} else if variable.to_string() == "TRANSACTION" && modifier.is_none() {
if self.parse_keyword(Keyword::SNAPSHOT) {
let snaphot_id = self.parse_value()?;
let snapshot_id = self.parse_value()?;
return Ok(Statement::SetTransaction {
modes: vec![],
snapshot: Some(snaphot_id),
snapshot: Some(snapshot_id),
session: false,
});
}

View file

@ -654,7 +654,7 @@ impl<'a> Tokenizer<'a> {
Ok(())
}
// Tokenize the identifer or keywords in `ch`
// Tokenize the identifier or keywords in `ch`
fn tokenize_identifier_or_keyword(
&self,
ch: impl IntoIterator<Item = char>,