MCPcopy Create free account
hub / github.com/apache/datafusion / new_from_existing

Method new_from_existing

datafusion/core/src/execution/session_state.rs:1107–1159  ·  view source on GitHub ↗

Returns a new [SessionStateBuilder] based on an existing [SessionState]. The session id for the new builder will be unset; all other fields will be cloned from `existing`. If the default catalog exists in existing session state, the new session state will not create default catalog and schema.

(existing: SessionState)

Source from the content-addressed store, hash-verified

1105 /// catalog exists in existing session state, the new session state will not
1106 /// create default catalog and schema.
1107 pub fn new_from_existing(existing: SessionState) -> Self {
1108 let default_catalog_exist = existing
1109 .catalog_list()
1110 .catalog(&existing.config.options().catalog.default_catalog)
1111 .is_some();
1112 // The new `with_create_default_catalog_and_schema` should be false if the default catalog exists
1113 let create_default_catalog_and_schema = existing
1114 .config
1115 .options()
1116 .catalog
1117 .create_default_catalog_and_schema
1118 && !default_catalog_exist;
1119 let new_config = existing
1120 .config
1121 .with_create_default_catalog_and_schema(create_default_catalog_and_schema);
1122 Self {
1123 session_id: None,
1124 analyzer: Some(existing.analyzer),
1125 expr_planners: Some(existing.expr_planners),
1126 #[cfg(feature = "sql")]
1127 relation_planners: Some(existing.relation_planners),
1128 #[cfg(feature = "sql")]
1129 type_planner: existing.type_planner,
1130 optimizer: Some(existing.optimizer),
1131 physical_optimizers: Some(existing.physical_optimizers),
1132 query_planner: Some(existing.query_planner),
1133 catalog_list: Some(existing.catalog_list),
1134 table_functions: Some(existing.table_functions),
1135 scalar_functions: Some(existing.scalar_functions.into_values().collect_vec()),
1136 higher_order_functions: Some(
1137 existing.higher_order_functions.into_values().collect_vec(),
1138 ),
1139 aggregate_functions: Some(
1140 existing.aggregate_functions.into_values().collect_vec(),
1141 ),
1142 window_functions: Some(existing.window_functions.into_values().collect_vec()),
1143 extension_types: Some(existing.extension_types),
1144 serializer_registry: Some(existing.serializer_registry),
1145 file_formats: Some(existing.file_formats.into_values().collect_vec()),
1146 config: Some(new_config),
1147 table_options: Some(existing.table_options),
1148 execution_props: Some(existing.execution_props),
1149 table_factories: Some(existing.table_factories),
1150 runtime_env: Some(existing.runtime_env),
1151 function_factory: existing.function_factory,
1152 cache_factory: existing.cache_factory,
1153 statistics_registry: existing.statistics_registry,
1154 // fields to support convenience functions
1155 analyzer_rules: None,
1156 optimizer_rules: None,
1157 physical_optimizer_rules: None,
1158 }
1159 }
1160
1161 /// Adds defaults for table_factories, file formats, expr_planners and builtin
1162 /// scalar, aggregate and windows functions.

Callers

nothing calls this directly

Calls 4

catalog_listMethod · 0.80
catalogMethod · 0.45
optionsMethod · 0.45

Tested by

no test coverage detected