-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
improve error message for invalid create table statement #1294
Conversation
datafusion/src/sql/planner.rs
Outdated
{ | ||
let plan = self.query_to_plan(query)?; | ||
} => { | ||
if columns.is_empty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: I prefer match
guard to if
here. Just like other options(or_replace
, if_not_exists
, etc) are being pattern matched.
Because it feel like bit confusing to see different error messages across different create table variants.
❯ create table a;
NotImplemented("Unsupported SQL statement: CreateTable { or_replace: false, temporary: false, external: false, if_not_exists: false, name: ObjectName([Ident { value: \"a\", quote_style: None }]), columns: [], constraints: [], hive_distribution: NONE, hive_formats: Some(HiveFormat { row_format: None, storage: None, location: None }), table_properties: [], with_options: [], file_format: None, location: None, query: None, without_rowid: false, like: None }")
❯ create table if not exists a as select 1 as col1;
NotImplemented("Unsupported SQL statement: CreateTable { or_replace: false, temporary: false, external: false, if_not_exists: true, name: ObjectName([Ident { value: \"a\", quote_style: None }]), columns: [], constraints: [], hive_distribution: NONE, hive_formats: Some(HiveFormat { row_format: None, storage: None, location: None }), table_properties: [], with_options: [], file_format: None, location: None, query: Some(Query { with: None, body: Select(Select { distinct: false, top: None, projection: [ExprWithAlias { expr: Value(Number(\"1\", false)), alias: Ident { value: \"col1\", quote_style: None } }], from: [], lateral_views: [], selection: None, group_by: [], cluster_by: [], distribute_by: [], sort_by: [], having: None }), order_by: [], limit: None, offset: None, fetch: None }), without_rowid: false, like: None }")
❯ create table a(id string) as select 1 as col1;
NotImplemented("Only `CREATE TABLE table_name AS SELECT ...` statement is supported")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I have pushed a new commit to address this.
"Only SELECT statements are implemented".to_string(), | ||
)), | ||
_ => Err(DataFusionError::NotImplemented(format!( | ||
"Unsupported SQL statement: {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
* improve error message for invalid create table statement * handle different create table cases using match
Rationale for this change
We show
Only SELECT statements are implemented
when user entered an invalid create table query in datafusion-cli, which is misleading.What changes are included in this PR?
Change the error message to make it match the features we have today.
Are there any user-facing changes?
no