feat: Support expression in SET statement (#574)

Co-authored-by: Alex Vasilev <vaspiring@gmail.com>
This commit is contained in:
Dmitry Patsura 2022-08-18 20:29:55 +03:00 committed by GitHub
parent eb7f1b005e
commit 6d8aacd85b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 52 deletions

View file

@ -15,7 +15,7 @@
//! Test SQL syntax specific to Hive. The parser based on the generic dialect
//! is also tested (on the inputs it can handle).
use sqlparser::ast::{CreateFunctionUsing, Ident, ObjectName, SetVariableValue, Statement};
use sqlparser::ast::{CreateFunctionUsing, Expr, Ident, ObjectName, Statement, UnaryOperator};
use sqlparser::dialect::{GenericDialect, HiveDialect};
use sqlparser::parser::ParserError;
use sqlparser::test_utils::*;
@ -220,14 +220,17 @@ fn set_statement_with_minus() {
Ident::new("java"),
Ident::new("opts")
]),
value: vec![SetVariableValue::Ident("-Xmx4g".into())],
value: vec![Expr::UnaryOp {
op: UnaryOperator::Minus,
expr: Box::new(Expr::Identifier(Ident::new("Xmx4g")))
}],
}
);
assert_eq!(
hive().parse_sql_statements("SET hive.tez.java.opts = -"),
Err(ParserError::ParserError(
"Expected word, found: EOF".to_string()
"Expected variable value, found: EOF".to_string()
))
)
}