mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Add support for BigQuery ANY TYPE
data type (#1602)
Co-authored-by: Martin Abelson Sahlen <sahlen@Martins-MacBook-Air.local> Co-authored-by: Martin Abelson Sahlen <sahlen@Mac.lan>
This commit is contained in:
parent
885aa93465
commit
7bc6ddb8fb
3 changed files with 25 additions and 1 deletions
|
@ -373,6 +373,10 @@ pub enum DataType {
|
|||
///
|
||||
/// [postgresql]: https://www.postgresql.org/docs/current/plpgsql-trigger.html
|
||||
Trigger,
|
||||
/// Any data type, used in BigQuery UDF definitions for templated parameters
|
||||
///
|
||||
/// [bigquery]: https://cloud.google.com/bigquery/docs/user-defined-functions#templated-sql-udf-parameters
|
||||
AnyType,
|
||||
}
|
||||
|
||||
impl fmt::Display for DataType {
|
||||
|
@ -383,7 +387,6 @@ impl fmt::Display for DataType {
|
|||
DataType::CharacterVarying(size) => {
|
||||
format_character_string_type(f, "CHARACTER VARYING", size)
|
||||
}
|
||||
|
||||
DataType::CharVarying(size) => format_character_string_type(f, "CHAR VARYING", size),
|
||||
DataType::Varchar(size) => format_character_string_type(f, "VARCHAR", size),
|
||||
DataType::Nvarchar(size) => format_character_string_type(f, "NVARCHAR", size),
|
||||
|
@ -626,6 +629,7 @@ impl fmt::Display for DataType {
|
|||
}
|
||||
DataType::Unspecified => Ok(()),
|
||||
DataType::Trigger => write!(f, "TRIGGER"),
|
||||
DataType::AnyType => write!(f, "ANY TYPE"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8382,6 +8382,10 @@ impl<'a> Parser<'a> {
|
|||
Ok(DataType::Tuple(field_defs))
|
||||
}
|
||||
Keyword::TRIGGER => Ok(DataType::Trigger),
|
||||
Keyword::ANY if self.peek_keyword(Keyword::TYPE) => {
|
||||
let _ = self.parse_keyword(Keyword::TYPE);
|
||||
Ok(DataType::AnyType)
|
||||
}
|
||||
_ => {
|
||||
self.prev_token();
|
||||
let type_name = self.parse_object_name(false)?;
|
||||
|
|
|
@ -2212,3 +2212,19 @@ fn test_any_value() {
|
|||
bigquery_and_generic().verified_expr("ANY_VALUE(fruit HAVING MAX sold)");
|
||||
bigquery_and_generic().verified_expr("ANY_VALUE(fruit HAVING MIN sold)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_any_type() {
|
||||
bigquery().verified_stmt(concat!(
|
||||
"CREATE OR REPLACE TEMPORARY FUNCTION ",
|
||||
"my_function(param1 ANY TYPE) ",
|
||||
"AS (",
|
||||
"(SELECT 1)",
|
||||
")",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_any_type_dont_break_custom_type() {
|
||||
bigquery_and_generic().verified_stmt("CREATE TABLE foo (x ANY)");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue