File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
datafusion-postgres-cli/src Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ async fn setup_session_context(
171171 }
172172
173173 // Register pg_catalog
174- setup_pg_catalog ( session_context) ?;
174+ setup_pg_catalog ( session_context, "datafusion" ) ?;
175175
176176 Ok ( ( ) )
177177}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use datafusion::catalog::streaming::StreamingTable;
1010use datafusion:: catalog:: { CatalogProviderList , MemTable , SchemaProvider } ;
1111use datafusion:: common:: utils:: SingleRowListArrayBuilder ;
1212use datafusion:: datasource:: TableProvider ;
13- use datafusion:: error:: Result ;
13+ use datafusion:: error:: { DataFusionError , Result } ;
1414use datafusion:: execution:: { SendableRecordBatchStream , TaskContext } ;
1515use datafusion:: logical_expr:: { ColumnarValue , ScalarUDF , Volatility } ;
1616use datafusion:: physical_plan:: stream:: RecordBatchStreamAdapter ;
@@ -653,11 +653,16 @@ pub fn create_current_schema_udf() -> ScalarUDF {
653653}
654654
655655/// Install pg_catalog and postgres UDFs to current `SessionContext`
656- pub fn setup_pg_catalog ( session_context : & SessionContext ) -> Result < ( ) > {
656+ pub fn setup_pg_catalog ( session_context : & SessionContext , catalog_name : & str ) -> Result < ( ) > {
657657 let pg_catalog = PgCatalogSchemaProvider :: new ( session_context. state ( ) . catalog_list ( ) . clone ( ) ) ;
658658 session_context
659- . catalog ( "datafusion" )
660- . unwrap ( )
659+ . catalog ( catalog_name)
660+ . ok_or_else ( || {
661+ DataFusionError :: Configuration ( format ! (
662+ "Catalog not found when registering pg_catalog: {}" ,
663+ catalog_name
664+ ) )
665+ } ) ?
661666 . register_schema ( "pg_catalog" , Arc :: new ( pg_catalog) ) ?;
662667
663668 session_context. register_udf ( create_current_schema_udf ( ) ) ;
You can’t perform that action at this time.
0 commit comments