NoahKusaba commented on PR #2974:
URL: 
https://github.com/apache/datafusion-ballista/pull/2974#issuecomment-7286636225

   The diagnosis is right, but I think there's a smaller fix. 
`new_from_existing` already turns `create_default_catalog_and_schema` off when 
the default catalog exists; the bug is that `.with_config(session_config)` 
overwrites that. Instead of copying the check, upgrade the state's own config 
and drop `with_config` (untested sketch):
   
   ```rust
   let upgraded = self.config().clone().upgrade_for_ballista();
   *self.config_mut() = upgraded;
   let create_default_catalog =
       self.config().options().catalog.create_default_catalog_and_schema;
   
   let builder = SessionStateBuilder::new_from_existing(self) // no 
.with_config(...)
   // ...
   let mut state = builder./* ... */build();
   state.config_mut().options_mut().catalog.create_default_catalog_and_schema =
       create_default_catalog;
   ```
   
   The last line matters: otherwise the `false` stays in the context's config, 
and `execute_query_params` sends it to the scheduler (and executors via task 
props). An `override_session_builder` that builds with 
`SessionStateBuilder::new().with_config(config)` then gets no default catalog, 
but only for `*_with_state` clients. The flag is only read in `build()`, so 
restoring it afterwards is safe.
   
   Tests: please assert the flag survives (`information_schema.df_settings` + 
`assert_batches_eq!`), and in `should_create_missing_default_catalog` compare 
the full `catalog_names()`/`schema_names()` rather than `is_some()`.
   
   Minor: UDFs registered on the state are still dropped 
(`with_scalar_functions` replaces the list), so the description's "as with 
`new_with_state`" holds only for tables.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to