NoahKusaba opened a new issue, #2960:
URL: https://github.com/apache/datafusion-ballista/issues/2960

   **Describe the bug**
   
   Tables registered on a `SessionState` before 
`SessionContext::standalone_with_state` or `remote_with_state` are gone 
afterwards: `table 'datafusion.public.<name>' not found`.
   
   `upgrade_for_ballista` rebuilds the state with 
`SessionStateBuilder::new_from_existing(self).with_config(session_config)`. 
`new_from_existing` turns off `create_default_catalog_and_schema` when the 
default catalog already exists. But `with_config` then replaces that config 
with the state's original one, where the flag is still `true`. So `build()` 
registers a fresh, empty default catalog over the existing one. With 
`RUST_LOG=datafusion::execution::session_state=debug`, this logs `Overwrote the 
default catalog`.
   
   **To Reproduce**
   
   ```rust
   let config = SessionConfig::new_with_ballista();
   let setup = SessionContext::new_with_state(
       
SessionStateBuilder::new().with_config(config).with_default_features().build(),
   );
   setup.register_csv("pre", "pre.csv", CsvReadOptions::new()).await?;
   
   let ctx = SessionContext::standalone_with_state(setup.state()).await?;
   ctx.sql("SELECT * FROM pre").await?.collect().await?;
   // Error during planning: table 'datafusion.public.pre' not found
   ```
   
   **Expected behavior**
   
   The table is still registered, as it is with 
`SessionContext::new_with_state(setup.state())`.
   
   **Additional context**
   
   Found by running DataFusion's sqllogictest files on Ballista (#2945): 154 
records in files whose `TestContext` registers tables up front (`metadata.slt`, 
`range_partitioning.slt`, `dictionary_struct.slt`, 
`parquet_missing_bounds.slt`, …). Setting `create_default_catalog_and_schema = 
false` on the config before the upgrade, or keeping the flag 
`new_from_existing` sets, would avoid it.
   


-- 
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