forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor_setting.rs
More file actions
56 lines (48 loc) · 1.5 KB
/
executor_setting.rs
File metadata and controls
56 lines (48 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2020 The FuseQuery Authors.
//
// Code is licensed under AGPL License, Version 3.0.
use async_trait::async_trait;
use log::debug;
use std::sync::Arc;
use crate::contexts::FuseQueryContextRef;
use crate::datastreams::{DataBlockStream, SendableDataBlockStream};
use crate::datavalues::{DataField, DataSchema, DataType};
use crate::error::FuseQueryResult;
use crate::executors::IExecutor;
use crate::planners::SettingPlan;
pub struct SettingExecutor {
ctx: FuseQueryContextRef,
set: SettingPlan,
}
impl SettingExecutor {
pub fn try_create(
ctx: FuseQueryContextRef,
set: SettingPlan,
) -> FuseQueryResult<Arc<dyn IExecutor>> {
Ok(Arc::new(SettingExecutor { ctx, set }))
}
}
#[async_trait]
impl IExecutor for SettingExecutor {
fn name(&self) -> &str {
"SetVariableExecutor"
}
async fn execute(&self) -> FuseQueryResult<SendableDataBlockStream> {
let plan = self.set.clone();
match plan.variable.to_lowercase().as_str() {
// To be compatible with some drivers
// eg: usql and mycli
"sql_mode" | "autocommit" => {}
_ => {
self.ctx.update_settings(&plan.variable, plan.value)?;
}
}
debug!("Set variable executor: {:?}", self.ctx);
let schema = Arc::new(DataSchema::new(vec![DataField::new(
"set",
DataType::Utf8,
false,
)]));
Ok(Box::pin(DataBlockStream::create(schema, None, vec![])))
}
}