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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an unquoting function for sqlparser ASTs #267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,15 +1245,18 @@ impl SeafowlContext for DefaultSeafowlContext {

async fn create_logical_plan(&self, sql: &str) -> Result<LogicalPlan> {
let mut statements = self.parse_query(sql).await?;
println!("create_logical_plan() statements {:?}", statements);

if statements.len() != 1 {
return Err(Error::NotImplemented(
"The context currently only supports a single SQL statement".to_string(),
));
}

self.create_logical_plan_from_statement(statements.pop().unwrap())
.await
let plan = self.create_logical_plan_from_statement(statements.pop().unwrap())
.await;
println!("create_logical_plan() plan {:?}", plan);
plan
}

async fn plan_query(&self, sql: &str) -> Result<Arc<dyn ExecutionPlan>> {
Expand Down Expand Up @@ -2034,6 +2037,21 @@ mod tests {
assert_eq!(expected.into_iter().sorted().collect_vec(), actual);
}

async fn get_logical_plan(query: &str) -> String {
let sf_context = mock_context().await;
let plan = sf_context.create_logical_plan(query).await.unwrap();
format!("{:?}", plan)
}

#[tokio::test]
async fn test_create_schema_name_in_quotes() {

assert_eq!(
get_logical_plan("CREATE SCHEMA \"schema_name\"").await,
"Create: table_name"
);
}

#[rstest]
#[case::in_memory_object_store_standard(false)]
#[case::local_object_store_test_renames(true)]
Expand Down
1 change: 1 addition & 0 deletions src/datafusion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
pub mod parser;
pub mod utils;
pub mod visit;
pub mod unquote;
Loading