This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 4195f2f367 Minor: Add sql level test for inserting into non-existent 
directory (#8278)
4195f2f367 is described below

commit 4195f2f367648f9c2ed990f2948248e53f503f9b
Author: Andrew Lamb <[email protected]>
AuthorDate: Mon Nov 20 11:08:12 2023 -0500

    Minor: Add sql level test for inserting into non-existent directory (#8278)
---
 datafusion/sqllogictest/test_files/insert.slt | 36 +++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/datafusion/sqllogictest/test_files/insert.slt 
b/datafusion/sqllogictest/test_files/insert.slt
index a100b5ac6b..aacd227cdb 100644
--- a/datafusion/sqllogictest/test_files/insert.slt
+++ b/datafusion/sqllogictest/test_files/insert.slt
@@ -314,3 +314,39 @@ select * from table_without_values;
 
 statement ok
 drop table table_without_values;
+
+
+### Test for creating tables into directories that do not already exist
+# note use of `scratch` directory (which is cleared between runs)
+
+statement ok
+create external table new_empty_table(x int) stored as parquet  location 
'test_files/scratch/insert/new_empty_table/'; -- needs trailing slash
+
+# should start empty
+query I
+select * from new_empty_table;
+----
+
+# should succeed and the table should create the direectory
+statement ok
+insert into new_empty_table values (1);
+
+# Now has values
+query I
+select * from new_empty_table;
+----
+1
+
+statement ok
+drop table new_empty_table;
+
+## test we get an error if the path doesn't end in slash
+statement ok
+create external table bad_new_empty_table(x int) stored as parquet  location 
'test_files/scratch/insert/bad_new_empty_table'; -- no trailing slash
+
+# should fail
+query error DataFusion error: Error during planning: Inserting into a 
ListingTable backed by a single file is not supported, URL is possibly missing 
a trailing `/`\. To append to an existing file use StreamTable, e\.g\. by using 
CREATE UNBOUNDED EXTERNAL TABLE
+insert into bad_new_empty_table values (1);
+
+statement ok
+drop table bad_new_empty_table;

Reply via email to