You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/01/23 12:11:55 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5026: [sqllogictest] Create empty tables

alamb commented on code in PR #5026:
URL: https://github.com/apache/arrow-datafusion/pull/5026#discussion_r1083980025


##########
datafusion/sql/src/planner.rs:
##########
@@ -114,7 +114,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         }
     }
 
-    pub(crate) fn build_schema(&self, columns: Vec<SQLColumnDef>) -> Result<Schema> {
+    pub fn build_schema(&self, columns: Vec<SQLColumnDef>) -> Result<Schema> {

Review Comment:
   I think this is fine to make public 👍 



##########
datafusion/core/tests/sqllogictests/test_files/ddl.slt:
##########
@@ -419,3 +419,49 @@ SELECT * FROM aggregate_simple order by c1 DESC LIMIT 1;
 
 statement ok
 DROP TABLE aggregate_simple
+
+
+# Should create an empty table
+statement ok
+CREATE TABLE table_without_values(field1 BIGINT, field2 BIGINT);
+
+
+# Should skip existing table
+statement ok
+CREATE TABLE IF NOT EXISTS table_without_values(field1 BIGINT, field2 BIGINT);
+
+
+# Should not recreate the same table
+statement error Table 'table_without_values' already exists
+CREATE TABLE table_without_values(field1 BIGINT, field2 BIGINT);
+
+
+# 'IF NOT EXISTS' cannot coexist with 'REPLACE'
+statement error Execution error: 'IF NOT EXISTS' cannot coexist with 'REPLACE'
+CREATE OR REPLACE TABLE IF NOT EXISTS table_without_values(field1 BIGINT, field2 BIGINT);
+
+# Should insert into an empty table
+statement ok
+insert into table_without_values values (1, 2), (2, 3), (2, 4);

Review Comment:
   👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org