mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 14:28:22 +00:00
Add GLOBAL context/modifier to SET statements (#1767)
This commit is contained in:
parent
e3e88290cd
commit
f487cbe004
7 changed files with 72 additions and 39 deletions
|
@ -8627,12 +8627,12 @@ fn parse_set_transaction() {
|
|||
fn parse_set_variable() {
|
||||
match verified_stmt("SET SOMETHING = '1'") {
|
||||
Statement::Set(Set::SingleAssignment {
|
||||
local,
|
||||
scope,
|
||||
hivevar,
|
||||
variable,
|
||||
values,
|
||||
}) => {
|
||||
assert!(!local);
|
||||
assert_eq!(scope, ContextModifier::None);
|
||||
assert!(!hivevar);
|
||||
assert_eq!(variable, ObjectName::from(vec!["SOMETHING".into()]));
|
||||
assert_eq!(
|
||||
|
@ -8645,6 +8645,26 @@ fn parse_set_variable() {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
match verified_stmt("SET GLOBAL VARIABLE = 'Value'") {
|
||||
Statement::Set(Set::SingleAssignment {
|
||||
scope,
|
||||
hivevar,
|
||||
variable,
|
||||
values,
|
||||
}) => {
|
||||
assert_eq!(scope, ContextModifier::Global);
|
||||
assert!(!hivevar);
|
||||
assert_eq!(variable, ObjectName::from(vec!["VARIABLE".into()]));
|
||||
assert_eq!(
|
||||
values,
|
||||
vec![Expr::Value(
|
||||
(Value::SingleQuotedString("Value".into())).with_empty_span()
|
||||
)]
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let multi_variable_dialects = all_dialects_where(|d| d.supports_parenthesized_set_variables());
|
||||
let sql = r#"SET (a, b, c) = (1, 2, 3)"#;
|
||||
match multi_variable_dialects.verified_stmt(sql) {
|
||||
|
@ -8719,12 +8739,12 @@ fn parse_set_variable() {
|
|||
fn parse_set_role_as_variable() {
|
||||
match verified_stmt("SET role = 'foobar'") {
|
||||
Statement::Set(Set::SingleAssignment {
|
||||
local,
|
||||
scope,
|
||||
hivevar,
|
||||
variable,
|
||||
values,
|
||||
}) => {
|
||||
assert!(!local);
|
||||
assert_eq!(scope, ContextModifier::None);
|
||||
assert!(!hivevar);
|
||||
assert_eq!(variable, ObjectName::from(vec!["role".into()]));
|
||||
assert_eq!(
|
||||
|
@ -8766,12 +8786,12 @@ fn parse_double_colon_cast_at_timezone() {
|
|||
fn parse_set_time_zone() {
|
||||
match verified_stmt("SET TIMEZONE = 'UTC'") {
|
||||
Statement::Set(Set::SingleAssignment {
|
||||
local,
|
||||
scope,
|
||||
hivevar,
|
||||
variable,
|
||||
values,
|
||||
}) => {
|
||||
assert!(!local);
|
||||
assert_eq!(scope, ContextModifier::None);
|
||||
assert!(!hivevar);
|
||||
assert_eq!(variable, ObjectName::from(vec!["TIMEZONE".into()]));
|
||||
assert_eq!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue