mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-07 20:50:21 +00:00
Support for Map values in ClickHouse settings (#1896)
Some checks are pending
Rust / test (beta) (push) Waiting to run
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Some checks are pending
Rust / test (beta) (push) Waiting to run
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
parent
6c38cdcadb
commit
50c605a471
5 changed files with 112 additions and 43 deletions
|
@ -2770,7 +2770,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
if self.dialect.supports_dictionary_syntax() {
|
||||
self.prev_token(); // Put back the '{'
|
||||
return self.parse_duckdb_struct_literal();
|
||||
return self.parse_dictionary();
|
||||
}
|
||||
|
||||
self.expected("an expression", token)
|
||||
|
@ -3139,7 +3139,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(fields)
|
||||
}
|
||||
|
||||
/// DuckDB specific: Parse a duckdb [dictionary]
|
||||
/// DuckDB and ClickHouse specific: Parse a duckdb [dictionary] or a clickhouse [map] setting
|
||||
///
|
||||
/// Syntax:
|
||||
///
|
||||
|
@ -3148,18 +3148,18 @@ impl<'a> Parser<'a> {
|
|||
/// ```
|
||||
///
|
||||
/// [dictionary]: https://duckdb.org/docs/sql/data_types/struct#creating-structs
|
||||
fn parse_duckdb_struct_literal(&mut self) -> Result<Expr, ParserError> {
|
||||
/// [map]: https://clickhouse.com/docs/operations/settings/settings#additional_table_filters
|
||||
fn parse_dictionary(&mut self) -> Result<Expr, ParserError> {
|
||||
self.expect_token(&Token::LBrace)?;
|
||||
|
||||
let fields =
|
||||
self.parse_comma_separated0(Self::parse_duckdb_dictionary_field, Token::RBrace)?;
|
||||
let fields = self.parse_comma_separated0(Self::parse_dictionary_field, Token::RBrace)?;
|
||||
|
||||
self.expect_token(&Token::RBrace)?;
|
||||
|
||||
Ok(Expr::Dictionary(fields))
|
||||
}
|
||||
|
||||
/// Parse a field for a duckdb [dictionary]
|
||||
/// Parse a field for a duckdb [dictionary] or a clickhouse [map] setting
|
||||
///
|
||||
/// Syntax
|
||||
///
|
||||
|
@ -3168,7 +3168,8 @@ impl<'a> Parser<'a> {
|
|||
/// ```
|
||||
///
|
||||
/// [dictionary]: https://duckdb.org/docs/sql/data_types/struct#creating-structs
|
||||
fn parse_duckdb_dictionary_field(&mut self) -> Result<DictionaryField, ParserError> {
|
||||
/// [map]: https://clickhouse.com/docs/operations/settings/settings#additional_table_filters
|
||||
fn parse_dictionary_field(&mut self) -> Result<DictionaryField, ParserError> {
|
||||
let key = self.parse_identifier()?;
|
||||
|
||||
self.expect_token(&Token::Colon)?;
|
||||
|
@ -11216,7 +11217,7 @@ impl<'a> Parser<'a> {
|
|||
let key_values = self.parse_comma_separated(|p| {
|
||||
let key = p.parse_identifier()?;
|
||||
p.expect_token(&Token::Eq)?;
|
||||
let value = p.parse_value()?.value;
|
||||
let value = p.parse_expr()?;
|
||||
Ok(Setting { key, value })
|
||||
})?;
|
||||
Some(key_values)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue