Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return proper error message for ill formed variable reference #3162

Merged
merged 1 commit into from Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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