BigQuery: support unquoted hyphen in table/view declaration (#1178)

This commit is contained in:
Ifeanyi Ubah 2024-04-09 23:05:31 +02:00 committed by GitHub
parent 241da85d67
commit 8dd213cff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 4 deletions

View file

@ -3749,7 +3749,8 @@ impl<'a> Parser<'a> {
&& self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
// Many dialects support `OR ALTER` right after `CREATE`, but we don't (yet).
// ANSI SQL and Postgres support RECURSIVE here, but we don't support it either.
let name = self.parse_object_name(false)?;
let allow_unquoted_hyphen = dialect_of!(self is BigQueryDialect);
let name = self.parse_object_name(allow_unquoted_hyphen)?;
let columns = self.parse_view_columns()?;
let mut options = CreateTableOptions::None;
let with_options = self.parse_options(Keyword::WITH)?;
@ -4736,8 +4737,9 @@ impl<'a> Parser<'a> {
global: Option<bool>,
transient: bool,
) -> Result<Statement, ParserError> {
let allow_unquoted_hyphen = dialect_of!(self is BigQueryDialect);
let if_not_exists = self.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
let table_name = self.parse_object_name(false)?;
let table_name = self.parse_object_name(allow_unquoted_hyphen)?;
// Clickhouse has `ON CLUSTER 'cluster'` syntax for DDLs
let on_cluster = if self.parse_keywords(&[Keyword::ON, Keyword::CLUSTER]) {
@ -4752,13 +4754,13 @@ impl<'a> Parser<'a> {
};
let like = if self.parse_keyword(Keyword::LIKE) || self.parse_keyword(Keyword::ILIKE) {
self.parse_object_name(false).ok()
self.parse_object_name(allow_unquoted_hyphen).ok()
} else {
None
};
let clone = if self.parse_keyword(Keyword::CLONE) {
self.parse_object_name(false).ok()
self.parse_object_name(allow_unquoted_hyphen).ok()
} else {
None
};