@@ -299,35 +299,13 @@ impl ExecutionContext {
299
299
let schema = catalog. schema ( & schema_name) ;
300
300
301
301
match ( if_not_exists, schema) {
302
- //
303
302
( true , Some ( _) ) => {
304
- println ! ( "Schema '{:?}' already exists" , & schema_name) ;
305
303
let plan = LogicalPlanBuilder :: empty ( false ) . build ( ) ?;
306
304
Ok ( Arc :: new ( DataFrameImpl :: new ( self . state . clone ( ) , & plan) ) )
307
305
}
308
306
( true , None ) | ( false , None ) => {
309
- println ! ( "Creating schema {:?}" , schema_name) ;
310
307
let schema = Arc :: new ( MemorySchemaProvider :: new ( ) ) ;
311
- let plan = LogicalPlanBuilder :: empty ( false ) . build ( ) ?;
312
- schema. register_table (
313
- "test" . into ( ) ,
314
- Arc :: new ( DataFrameImpl :: new ( self . state . clone ( ) , & plan) ) ,
315
- ) ?;
316
- let schem_reg_res = catalog. register_schema ( & schema_name, schema) ;
317
- match schem_reg_res {
318
- Some ( _) => {
319
- println ! ( "Existing schema with name" )
320
- }
321
- None => {
322
- println ! ( "Succesfully registerd" )
323
- }
324
- } ;
325
- // println!("Schemas pre reg: {:?}", catalog.schema_names);
326
- self . register_catalog ( default_catalog, catalog) ;
327
- println ! (
328
- "Schema names: {:?}" ,
329
- self . catalog( default_catalog) . unwrap( ) . schema_names( )
330
- ) ;
308
+ catalog. register_schema ( & schema_name, schema) ;
331
309
let plan = LogicalPlanBuilder :: empty ( false ) . build ( ) ?;
332
310
Ok ( Arc :: new ( DataFrameImpl :: new ( self . state . clone ( ) , & plan) ) )
333
311
}
@@ -1217,10 +1195,6 @@ impl ExecutionContextState {
1217
1195
table_ref : impl Into < TableReference < ' a > > ,
1218
1196
) -> Result < Arc < dyn SchemaProvider > > {
1219
1197
let resolved_ref = self . resolve_table_ref ( table_ref. into ( ) ) ;
1220
- println ! (
1221
- "Resolved ref: {:?}:{:?}:{:?}" ,
1222
- resolved_ref. catalog, resolved_ref. schema, resolved_ref. table
1223
- ) ;
1224
1198
1225
1199
self . catalog_list
1226
1200
. catalog ( resolved_ref. catalog )
@@ -2954,6 +2928,29 @@ mod tests {
2954
2928
assert_eq ! ( Weak :: strong_count( & catalog_weak) , 0 ) ;
2955
2929
}
2956
2930
2931
+ #[ tokio:: test]
2932
+ async fn sql_create_schema ( ) -> Result < ( ) > {
2933
+ // the information schema used to introduce cyclic Arcs
2934
+ let mut ctx = ExecutionContext :: with_config (
2935
+ ExecutionConfig :: new ( ) . with_information_schema ( true ) ,
2936
+ ) ;
2937
+
2938
+ // Create schema
2939
+ ctx. sql ( "CREATE SCHEMA abc" ) . await ?. collect ( ) . await ?;
2940
+
2941
+ // Add table to schema
2942
+ ctx. sql ( "CREATE TABLE abc.y AS VALUES (1,2,3)" )
2943
+ . await ?
2944
+ . collect ( )
2945
+ . await ?;
2946
+
2947
+ // Check table exists in schema
2948
+ let results = ctx. sql ( "SELECT * FROM information_schema.tables WHERE table_schema='abc' AND table_name = 'y'" ) . await . unwrap ( ) . collect ( ) . await . unwrap ( ) ;
2949
+
2950
+ assert_eq ! ( results[ 0 ] . num_rows( ) , 1 ) ;
2951
+ Ok ( ( ) )
2952
+ }
2953
+
2957
2954
#[ tokio:: test]
2958
2955
async fn normalized_column_identifiers ( ) {
2959
2956
// create local execution context
0 commit comments