capkurmagati commented on a change in pull request #1294:
URL: https://github.com/apache/arrow-datafusion/pull/1294#discussion_r748824405



##########
File path: datafusion/src/sql/planner.rs
##########
@@ -150,17 +150,24 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 external: false,
                 if_not_exists: false,
                 without_rowid: _without_row_id,
-            } if columns.is_empty()
-                && constraints.is_empty()
-                && table_properties.is_empty()
-                && with_options.is_empty() =>
-            {
-                let plan = self.query_to_plan(query)?;
+            } => {
+                if columns.is_empty()

Review comment:
       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")
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to