Encapsulate CreateFunction (#1573)

This commit is contained in:
Philip Cristiano 2024-12-02 12:45:14 -05:00 committed by GitHub
parent bd750dfada
commit e16b24679a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 149 additions and 148 deletions

View file

@ -2011,7 +2011,7 @@ fn test_bigquery_create_function() {
let stmt = bigquery().verified_stmt(sql);
assert_eq!(
stmt,
Statement::CreateFunction {
Statement::CreateFunction(CreateFunction {
or_replace: true,
temporary: true,
if_not_exists: false,
@ -2036,7 +2036,7 @@ fn test_bigquery_create_function() {
remote_connection: None,
called_on_null: None,
parallel: None,
}
})
);
let sqls = [

View file

@ -21,9 +21,10 @@
//! is also tested (on the inputs it can handle).
use sqlparser::ast::{
ClusteredBy, CommentDef, CreateFunctionBody, CreateFunctionUsing, CreateTable, Expr, Function,
FunctionArgumentList, FunctionArguments, Ident, ObjectName, OneOrManyWithParens, OrderByExpr,
SelectItem, Statement, TableFactor, UnaryOperator, Use, Value,
ClusteredBy, CommentDef, CreateFunction, CreateFunctionBody, CreateFunctionUsing, CreateTable,
Expr, Function, FunctionArgumentList, FunctionArguments, Ident, ObjectName,
OneOrManyWithParens, OrderByExpr, SelectItem, Statement, TableFactor, UnaryOperator, Use,
Value,
};
use sqlparser::dialect::{GenericDialect, HiveDialect, MsSqlDialect};
use sqlparser::parser::ParserError;
@ -392,13 +393,13 @@ fn set_statement_with_minus() {
fn parse_create_function() {
let sql = "CREATE TEMPORARY FUNCTION mydb.myfunc AS 'org.random.class.Name' USING JAR 'hdfs://somewhere.com:8020/very/far'";
match hive().verified_stmt(sql) {
Statement::CreateFunction {
Statement::CreateFunction(CreateFunction {
temporary,
name,
function_body,
using,
..
} => {
}) => {
assert!(temporary);
assert_eq!(name.to_string(), "mydb.myfunc");
assert_eq!(

View file

@ -3631,7 +3631,7 @@ fn parse_create_function() {
let sql = "CREATE FUNCTION add(INTEGER, INTEGER) RETURNS INTEGER LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'select $1 + $2;'";
assert_eq!(
pg_and_generic().verified_stmt(sql),
Statement::CreateFunction {
Statement::CreateFunction(CreateFunction {
or_replace: false,
temporary: false,
name: ObjectName(vec![Ident::new("add")]),
@ -3652,7 +3652,7 @@ fn parse_create_function() {
determinism_specifier: None,
options: None,
remote_connection: None,
}
})
);
}
@ -4987,7 +4987,7 @@ fn parse_trigger_related_functions() {
assert_eq!(
create_function,
Statement::CreateFunction {
Statement::CreateFunction(CreateFunction {
or_replace: false,
temporary: false,
if_not_exists: false,
@ -5017,7 +5017,7 @@ fn parse_trigger_related_functions() {
options: None,
remote_connection: None
}
);
));
// Check the third statement