Support CREATE FUNCTION for BigQuery (#1253)

This commit is contained in:
Ifeanyi Ubah 2024-05-30 18:18:41 +02:00 committed by GitHub
parent d5faf3c54b
commit 792e389baa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 557 additions and 173 deletions

View file

@ -17,8 +17,8 @@
use sqlparser::ast::{
CreateFunctionBody, CreateFunctionUsing, Expr, Function, FunctionArgumentList,
FunctionArguments, FunctionDefinition, Ident, ObjectName, OneOrManyWithParens, SelectItem,
Statement, TableFactor, UnaryOperator,
FunctionArguments, Ident, ObjectName, OneOrManyWithParens, SelectItem, Statement, TableFactor,
UnaryOperator, Value,
};
use sqlparser::dialect::{GenericDialect, HiveDialect, MsSqlDialect};
use sqlparser::parser::{ParserError, ParserOptions};
@ -296,22 +296,23 @@ fn parse_create_function() {
Statement::CreateFunction {
temporary,
name,
params,
function_body,
using,
..
} => {
assert!(temporary);
assert_eq!(name.to_string(), "mydb.myfunc");
assert_eq!(
params,
CreateFunctionBody {
as_: Some(FunctionDefinition::SingleQuotedDef(
"org.random.class.Name".to_string()
)),
using: Some(CreateFunctionUsing::Jar(
"hdfs://somewhere.com:8020/very/far".to_string()
)),
..Default::default()
}
function_body,
Some(CreateFunctionBody::AsBeforeOptions(Expr::Value(
Value::SingleQuotedString("org.random.class.Name".to_string())
)))
);
assert_eq!(
using,
Some(CreateFunctionUsing::Jar(
"hdfs://somewhere.com:8020/very/far".to_string()
)),
)
}
_ => unreachable!(),