mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Support postgres CREATE FUNCTION
(#722)
* support basic pg CREATE FUNCTION Signed-off-by: Runji Wang <wangrunji0408@163.com> * support function argument Signed-off-by: Runji Wang <wangrunji0408@163.com> * fix display and use verify in test Signed-off-by: Runji Wang <wangrunji0408@163.com> * support OR REPLACE Signed-off-by: Runji Wang <wangrunji0408@163.com> * fix compile error in bigdecimal Signed-off-by: Runji Wang <wangrunji0408@163.com> * unify all `CreateFunctionBody` to a structure Signed-off-by: Runji Wang <wangrunji0408@163.com> Signed-off-by: Runji Wang <wangrunji0408@163.com>
This commit is contained in:
parent
f621142f89
commit
5b53df97c4
5 changed files with 331 additions and 29 deletions
|
@ -16,8 +16,8 @@
|
|||
//! is also tested (on the inputs it can handle).
|
||||
|
||||
use sqlparser::ast::{
|
||||
CreateFunctionUsing, Expr, Function, Ident, ObjectName, SelectItem, Statement, TableFactor,
|
||||
UnaryOperator, Value,
|
||||
CreateFunctionBody, CreateFunctionUsing, Expr, Function, Ident, ObjectName, SelectItem,
|
||||
Statement, TableFactor, UnaryOperator, Value,
|
||||
};
|
||||
use sqlparser::dialect::{GenericDialect, HiveDialect};
|
||||
use sqlparser::parser::ParserError;
|
||||
|
@ -244,17 +244,20 @@ fn parse_create_function() {
|
|||
Statement::CreateFunction {
|
||||
temporary,
|
||||
name,
|
||||
class_name,
|
||||
using,
|
||||
params,
|
||||
..
|
||||
} => {
|
||||
assert!(temporary);
|
||||
assert_eq!("mydb.myfunc", name.to_string());
|
||||
assert_eq!("org.random.class.Name", class_name);
|
||||
assert_eq!(name.to_string(), "mydb.myfunc");
|
||||
assert_eq!(
|
||||
using,
|
||||
Some(CreateFunctionUsing::Jar(
|
||||
"hdfs://somewhere.com:8020/very/far".to_string()
|
||||
))
|
||||
params,
|
||||
CreateFunctionBody {
|
||||
as_: Some("org.random.class.Name".to_string()),
|
||||
using: Some(CreateFunctionUsing::Jar(
|
||||
"hdfs://somewhere.com:8020/very/far".to_string()
|
||||
)),
|
||||
..Default::default()
|
||||
}
|
||||
)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue