File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -721,9 +721,7 @@ impl<'a> TypeChecker<'a> {
721721 } => {
722722 let func_name = normalize_identifier ( name, self . name_resolution_ctx ) . to_string ( ) ;
723723 let func_name = func_name. as_str ( ) ;
724- if !is_builtin_function ( func_name)
725- && !Self :: all_sugar_functions ( ) . contains ( & func_name)
726- {
724+ if !is_builtin_function ( func_name) && !Self :: is_sugar_function ( func_name) {
727725 if let Some ( udf) = self . resolve_udf ( * span, func_name, args) ? {
728726 return Ok ( udf) ;
729727 } else {
@@ -3153,6 +3151,12 @@ impl<'a> TypeChecker<'a> {
31533151 ]
31543152 }
31553153
3154+ pub fn is_sugar_function ( name : & str ) -> bool {
3155+ Self :: all_sugar_functions ( )
3156+ . iter ( )
3157+ . any ( |func| func. eq_ignore_ascii_case ( name) )
3158+ }
3159+
31563160 fn try_rewrite_sugar_function (
31573161 & mut self ,
31583162 span : Span ,
Original file line number Diff line number Diff line change 1+ use databend_common_sql:: TypeChecker ;
2+
3+ #[ test]
4+ fn test_is_sugar_function_match ( ) {
5+ assert ! ( TypeChecker :: is_sugar_function( "database" ) ) ;
6+ assert ! ( TypeChecker :: is_sugar_function( "DATABASE" ) ) ;
7+ assert ! ( TypeChecker :: is_sugar_function( "version" ) ) ;
8+ assert ! ( TypeChecker :: is_sugar_function( "VERSION" ) ) ;
9+ assert ! ( TypeChecker :: is_sugar_function( "current_user" ) ) ;
10+ }
You can’t perform that action at this time.
0 commit comments