Omega359 commented on code in PR #11403:
URL: https://github.com/apache/datafusion/pull/11403#discussion_r1675887462
##########
datafusion/core/src/execution/session_state.rs:
##########
@@ -195,122 +196,10 @@ impl SessionState {
runtime: Arc<RuntimeEnv>,
catalog_list: Arc<dyn CatalogProviderList>,
) -> Self {
- let session_id = Uuid::new_v4().to_string();
-
- // Create table_factories for all default formats
- let mut table_factories: HashMap<String, Arc<dyn
TableProviderFactory>> =
- HashMap::new();
- #[cfg(feature = "parquet")]
- table_factories.insert("PARQUET".into(),
Arc::new(DefaultTableFactory::new()));
- table_factories.insert("CSV".into(),
Arc::new(DefaultTableFactory::new()));
- table_factories.insert("JSON".into(),
Arc::new(DefaultTableFactory::new()));
- table_factories.insert("NDJSON".into(),
Arc::new(DefaultTableFactory::new()));
- table_factories.insert("AVRO".into(),
Arc::new(DefaultTableFactory::new()));
- table_factories.insert("ARROW".into(),
Arc::new(DefaultTableFactory::new()));
-
- if config.create_default_catalog_and_schema() {
- let default_catalog = MemoryCatalogProvider::new();
-
- default_catalog
- .register_schema(
- &config.options().catalog.default_schema,
- Arc::new(MemorySchemaProvider::new()),
- )
- .expect("memory catalog provider can register schema");
-
- Self::register_default_schema(
- &config,
- &table_factories,
- &runtime,
- &default_catalog,
- );
-
- catalog_list.register_catalog(
- config.options().catalog.default_catalog.clone(),
- Arc::new(default_catalog),
- );
- }
-
- let expr_planners: Vec<Arc<dyn ExprPlanner>> = vec![
- Arc::new(functions::core::planner::CoreFunctionPlanner::default()),
- // register crate of array expressions (if enabled)
- #[cfg(feature = "array_expressions")]
- Arc::new(functions_array::planner::ArrayFunctionPlanner),
- #[cfg(feature = "array_expressions")]
- Arc::new(functions_array::planner::FieldAccessPlanner),
- #[cfg(any(
- feature = "datetime_expressions",
- feature = "unicode_expressions"
- ))]
- Arc::new(functions::planner::UserDefinedFunctionPlanner),
- ];
-
- let mut new_self = SessionState {
- session_id,
- analyzer: Analyzer::new(),
- expr_planners,
- optimizer: Optimizer::new(),
- physical_optimizers: PhysicalOptimizer::new(),
- query_planner: Arc::new(DefaultQueryPlanner {}),
- catalog_list,
- table_functions: HashMap::new(),
- scalar_functions: HashMap::new(),
- aggregate_functions: HashMap::new(),
- window_functions: HashMap::new(),
- serializer_registry: Arc::new(EmptySerializerRegistry),
- file_formats: HashMap::new(),
- table_options:
TableOptions::default_from_session_config(config.options()),
- config,
- execution_props: ExecutionProps::new(),
- runtime_env: runtime,
- table_factories,
- function_factory: None,
- };
-
- #[cfg(feature = "parquet")]
- if let Err(e) =
-
new_self.register_file_format(Arc::new(ParquetFormatFactory::new()), false)
- {
- log::info!("Unable to register default ParquetFormat: {e}")
- };
-
- if let Err(e) =
- new_self.register_file_format(Arc::new(JsonFormatFactory::new()),
false)
- {
- log::info!("Unable to register default JsonFormat: {e}")
- };
-
- if let Err(e) =
- new_self.register_file_format(Arc::new(CsvFormatFactory::new()),
false)
- {
- log::info!("Unable to register default CsvFormat: {e}")
- };
-
- if let Err(e) =
- new_self.register_file_format(Arc::new(ArrowFormatFactory::new()),
false)
- {
- log::info!("Unable to register default ArrowFormat: {e}")
- };
-
- if let Err(e) =
- new_self.register_file_format(Arc::new(AvroFormatFactory::new()),
false)
- {
- log::info!("Unable to register default AvroFormat: {e}")
- };
-
- // register built in functions
- functions::register_all(&mut new_self)
- .expect("can not register built in functions");
-
- // register crate of array expressions (if enabled)
- #[cfg(feature = "array_expressions")]
- functions_array::register_all(&mut new_self)
- .expect("can not register array expressions");
-
- functions_aggregate::register_all(&mut new_self)
- .expect("can not register aggregate functions");
-
- new_self
+ SessionStateBuilder::new_with_config_rt(config, runtime)
+ .with_defaults(true)
Review Comment:
I waffled back and forth as whether to have default set to false or true by,
um, default and decided that it would likely be best to mirror the current
system behavior. That being said, it's simple to change.
--
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]