Skip to content

Commit

Permalink
Return proper error message for ill formed variable reference (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Aug 16, 2022
1 parent 89bcfc4 commit f677e50
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion datafusion/core/src/execution/context.rs
Expand Up @@ -1561,7 +1561,8 @@ impl ContextProvider for SessionState {
return None;
}

let provider_type = if &variable_names[0][0..2] == "@@" {
let first_variable = &variable_names[0];
let provider_type = if first_variable.len() > 1 && &first_variable[0..2] == "@@" {
VarType::System
} else {
VarType::UserDefined
Expand Down Expand Up @@ -1857,6 +1858,21 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn create_variable_err() -> Result<()> {
let ctx = SessionContext::new();

let err = plan_and_collect(&ctx, "SElECT @= X#=?!~ 5")
.await
.unwrap_err();

assert_eq!(
err.to_string(),
"Execution error: variable [\"@\"] has no type information"
);
Ok(())
}

#[tokio::test]
async fn register_deregister() -> Result<()> {
let tmp_dir = TempDir::new()?;
Expand Down

0 comments on commit f677e50

Please sign in to comment.