@@ -4,7 +4,8 @@ use std::sync::Arc;
44
55use async_trait:: async_trait;
66use datafusion:: arrow:: array:: {
7- as_boolean_array, ArrayRef , AsArray , BooleanBuilder , RecordBatch , StringArray , StringBuilder ,
7+ as_boolean_array, ArrayRef , AsArray , BooleanBuilder , Int32Builder , RecordBatch , StringArray ,
8+ StringBuilder ,
89} ;
910use datafusion:: arrow:: datatypes:: { DataType , Field , Int32Type , SchemaRef } ;
1011use datafusion:: arrow:: ipc:: reader:: FileReader ;
@@ -32,6 +33,7 @@ pub mod pg_get_expr_udf;
3233pub mod pg_namespace;
3334pub mod pg_replication_slot;
3435pub mod pg_settings;
36+ pub mod pg_stat_gssapi;
3537pub mod pg_tables;
3638pub mod pg_views;
3739
@@ -100,6 +102,7 @@ const PG_CATALOG_VIEW_PG_SETTINGS: &str = "pg_settings";
100102const PG_CATALOG_VIEW_PG_VIEWS : & str = "pg_views" ;
101103const PG_CATALOG_VIEW_PG_MATVIEWS : & str = "pg_matviews" ;
102104const PG_CATALOG_VIEW_PG_TABLES : & str = "pg_tables" ;
105+ const PG_CATALOG_VIEW_PG_STAT_GSSAPI : & str = "pg_stat_gssapi" ;
103106const PG_CATALOG_VIEW_PG_STAT_USER_TABLES : & str = "pg_stat_user_tables" ;
104107const PG_CATALOG_VIEW_PG_REPLICATION_SLOTS : & str = "pg_replication_slots" ;
105108
@@ -339,6 +342,13 @@ impl<C: CatalogInfo> SchemaProvider for PgCatalogSchemaProvider<C> {
339342 vec ! [ table] ,
340343 ) ?) ) )
341344 }
345+ PG_CATALOG_VIEW_PG_STAT_GSSAPI => {
346+ let table = Arc :: new ( pg_stat_gssapi:: PgStatGssApiTable :: new ( ) ) ;
347+ Ok ( Some ( Arc :: new ( StreamingTable :: try_new (
348+ Arc :: clone ( table. schema ( ) ) ,
349+ vec ! [ table] ,
350+ ) ?) ) )
351+ }
342352 PG_CATALOG_VIEW_PG_TABLES => {
343353 let table = Arc :: new ( pg_tables:: PgTablesTable :: new ( self . catalog_list . clone ( ) ) ) ;
344354 Ok ( Some ( Arc :: new ( StreamingTable :: try_new (
@@ -1162,6 +1172,25 @@ pub fn create_pg_encoding_to_char_udf() -> ScalarUDF {
11621172 )
11631173}
11641174
1175+ pub fn create_pg_backend_pid_udf ( ) -> ScalarUDF {
1176+ let func = move |_args : & [ ColumnarValue ] | {
1177+ let mut builder = Int32Builder :: new ( ) ;
1178+ builder. append_value ( BACKEND_PID ) ;
1179+ let array: ArrayRef = Arc :: new ( builder. finish ( ) ) ;
1180+ Ok ( ColumnarValue :: Array ( array) )
1181+ } ;
1182+
1183+ create_udf (
1184+ "pg_backend_pid" ,
1185+ vec ! [ ] ,
1186+ DataType :: Int32 ,
1187+ Volatility :: Stable ,
1188+ Arc :: new ( func) ,
1189+ )
1190+ }
1191+
1192+ const BACKEND_PID : i32 = 1 ;
1193+
11651194/// Install pg_catalog and postgres UDFs to current `SessionContext`
11661195pub fn setup_pg_catalog (
11671196 session_context : & SessionContext ,
@@ -1207,6 +1236,7 @@ pub fn setup_pg_catalog(
12071236 session_context. register_udf ( create_pg_relation_is_publishable_udf ( ) ) ;
12081237 session_context. register_udf ( create_pg_get_statisticsobjdef_columns_udf ( ) ) ;
12091238 session_context. register_udf ( create_pg_encoding_to_char_udf ( ) ) ;
1239+ session_context. register_udf ( create_pg_backend_pid_udf ( ) ) ;
12101240
12111241 Ok ( ( ) )
12121242}
0 commit comments