mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Support CREATE FUNCTION for BigQuery (#1253)
This commit is contained in:
parent
d5faf3c54b
commit
792e389baa
6 changed files with 557 additions and 173 deletions
|
@ -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!(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue