Skip to content

Commit

Permalink
fix(query): set setting case insensitive (#15199)
Browse files Browse the repository at this point in the history
E.g.

```sql
SET GLOBAL data_retention_time_in_days=0; -- Need work
```
  • Loading branch information
TCeason authored Apr 9, 2024
1 parent d72f6aa commit c2e3ee6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/query/sql/src/planner/binder/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ impl Binder {
&[],
false,
)?;
let variable = variable.name.clone();

let (scalar, _) = *type_checker.resolve(value).await?;
let scalar = wrap_cast(&scalar, &DataType::String);
Expand All @@ -61,7 +60,7 @@ impl Binder {
let value = scalar.into_string().unwrap();
let vars = vec![VarValue {
is_global,
variable,
variable: variable.name.to_lowercase(),
value,
}];
Ok(Plan::SetVariable(Box::new(SettingPlan { vars })))
Expand All @@ -76,17 +75,16 @@ impl Binder {
_bind_context: &BindContext,
stmt: &UnSetStmt,
) -> Result<Plan> {
match stmt.clone().source {
match &stmt.source {
UnSetSource::Var { variable } => {
let variable = variable.name;
let vars = vec![variable];
let vars = vec![variable.name.to_lowercase()];
Ok(Plan::UnSetVariable(Box::new(UnSettingPlan { vars })))
}
UnSetSource::Vars { variables } => {
let mut vars: Vec<String> = vec![];
for var in variables {
vars.push(var.name.clone());
}
let vars: Vec<String> = variables
.iter()
.map(|var| var.name.to_lowercase())
.collect();
Ok(Plan::UnSetVariable(Box::new(UnSettingPlan { vars })))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@ SELECT name, value, default, level from system.settings where name in ('sql_dial
----
sql_dialect PostgreSQL PostgreSQL DEFAULT
timezone UTC UTC DEFAULT

statement ok
set DATA_RETENTION_TIME_IN_DAYS=20;

query TTTTTTT
show settings like 'DATA_RETENTION_TIME_IN_DAYS';
----
data_retention_time_in_days 20 1 [0, 90] SESSION Sets the data retention time in days. UInt64

statement ok
unset data_retention_time_in_days;

query TTTTTTT
show settings like 'DATA_RETENTION_TIME_IN_DAYS';
----
data_retention_time_in_days 1 1 [0, 90] DEFAULT Sets the data retention time in days. UInt64

0 comments on commit c2e3ee6

Please sign in to comment.