@@ -23,9 +23,10 @@ use datafusion::arrow::array::{ArrayRef, StringArray, as_boolean_array};
2323use datafusion:: catalog:: TableFunction ;
2424use datafusion:: common:: ScalarValue ;
2525use datafusion:: common:: utils:: SingleRowListArrayBuilder ;
26- use datafusion_expr:: { ColumnarValue , ScalarFunctionArgs , Signature , Volatility } ;
26+ use datafusion_expr:: { ColumnarValue , ScalarFunctionArgs , Signature , TypeSignature , Volatility } ;
2727use datafusion_pg_catalog:: pg_catalog:: { self , PgCatalogStaticTables } ;
2828use datatypes:: arrow:: datatypes:: { DataType , Field } ;
29+ use derive_more:: derive:: Display ;
2930use version:: PGVersionFunction ;
3031
3132use crate :: function:: { Function , find_function_context} ;
@@ -38,7 +39,6 @@ const SESSION_USER_FUNCTION_NAME: &str = "session_user";
3839const CURRENT_DATABASE_FUNCTION_NAME : & str = "current_database" ;
3940
4041define_nullary_udf ! ( CurrentSchemaFunction ) ;
41- define_nullary_udf ! ( CurrentSchemasFunction ) ;
4242define_nullary_udf ! ( SessionUserFunction ) ;
4343define_nullary_udf ! ( CurrentDatabaseFunction ) ;
4444
@@ -118,16 +118,33 @@ impl Function for SessionUserFunction {
118118 }
119119}
120120
121+ #[ derive( Display , Debug ) ]
122+ #[ display( "{}" , self . name( ) ) ]
123+ pub ( super ) struct CurrentSchemasFunction {
124+ signature : Signature ,
125+ }
126+
127+ impl CurrentSchemasFunction {
128+ pub fn new ( ) -> Self {
129+ Self {
130+ signature : Signature :: new (
131+ TypeSignature :: Exact ( vec ! [ DataType :: Boolean ] ) ,
132+ Volatility :: Stable ,
133+ ) ,
134+ }
135+ }
136+ }
137+
121138impl Function for CurrentSchemasFunction {
122139 fn name ( & self ) -> & str {
123140 CURRENT_SCHEMAS_FUNCTION_NAME
124141 }
125142
126143 fn return_type ( & self , _: & [ DataType ] ) -> datafusion_common:: Result < DataType > {
127144 Ok ( DataType :: List ( Arc :: new ( Field :: new (
128- "x " ,
129- DataType :: Utf8View ,
130- false ,
145+ "item " ,
146+ DataType :: Utf8 ,
147+ true ,
131148 ) ) ) )
132149 }
133150
@@ -168,7 +185,7 @@ impl PGCatalogFunction {
168185
169186 registry. register_scalar ( PGVersionFunction :: default ( ) ) ;
170187 registry. register_scalar ( CurrentSchemaFunction :: default ( ) ) ;
171- registry. register_scalar ( CurrentSchemasFunction :: default ( ) ) ;
188+ registry. register_scalar ( CurrentSchemasFunction :: new ( ) ) ;
172189 registry. register_scalar ( SessionUserFunction :: default ( ) ) ;
173190 registry. register_scalar ( CurrentDatabaseFunction :: default ( ) ) ;
174191 registry. register ( pg_catalog:: format_type:: create_format_type_udf ( ) ) ;
0 commit comments