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

Method set_variable

datafusion/core/src/execution/context/mod.rs:1115–1148  ·  view source on GitHub ↗
(&self, stmt: SetVariable)

Source from the content-addressed store, hash-verified

1113 }
1114
1115 async fn set_variable(&self, stmt: SetVariable) -> Result<()> {
1116 let SetVariable {
1117 variable, value, ..
1118 } = stmt;
1119
1120 // Check if this is a runtime configuration
1121 if variable.starts_with("datafusion.runtime.") {
1122 self.set_runtime_variable(&variable, &value)?;
1123 } else {
1124 let mut state = self.state.write();
1125 state.config_mut().options_mut().set(&variable, &value)?;
1126
1127 // Re-initialize any UDFs that depend on configuration
1128 // This allows both built-in and custom functions to respond to configuration changes
1129 let config_options = state.config().options();
1130
1131 // Collect updated UDFs in a separate vector
1132 let udfs_to_update: Vec<_> = state
1133 .scalar_functions()
1134 .values()
1135 .filter_map(|udf| {
1136 udf.inner()
1137 .with_updated_config(config_options)
1138 .map(Arc::new)
1139 })
1140 .collect();
1141
1142 for udf in udfs_to_update {
1143 state.register_udf(udf)?;
1144 }
1145 }
1146
1147 Ok(())
1148 }
1149
1150 async fn reset_variable(&self, stmt: ResetVariable) -> Result<()> {
1151 let variable = stmt.variable;

Callers 1

execute_logical_planMethod · 0.80

Calls 14

set_runtime_variableMethod · 0.80
options_mutMethod · 0.80
config_mutMethod · 0.80
collectMethod · 0.80
writeMethod · 0.45
setMethod · 0.45
optionsMethod · 0.45
configMethod · 0.45
valuesMethod · 0.45
scalar_functionsMethod · 0.45
mapMethod · 0.45
with_updated_configMethod · 0.45

Tested by

no test coverage detected