Skip to content

Commit 39bdb51

Browse files
committed
Minor: Add sql level test for inserting into non-existent directory
1 parent 2156dde commit 39bdb51

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

datafusion/sqllogictest/test_files/insert.slt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,39 @@ select * from table_without_values;
314314

315315
statement ok
316316
drop table table_without_values;
317+
318+
319+
### Test for creating tables into directories that do not already exist
320+
# note use of `scratch` directory (which is cleared between runs)
321+
322+
statement ok
323+
create external table new_empty_table(x int) stored as parquet location 'test_files/scratch/insert/new_empty_table/'; -- needs trailing slash
324+
325+
# should start empty
326+
query I
327+
select * from new_empty_table;
328+
----
329+
330+
# should succeed and the table should create the direectory
331+
statement ok
332+
insert into new_empty_table values (1);
333+
334+
# Now has values
335+
query I
336+
select * from new_empty_table;
337+
----
338+
1
339+
340+
statement ok
341+
drop table new_empty_table;
342+
343+
## test we get an error if the path doesn't end in slash
344+
statement ok
345+
create external table bad_new_empty_table(x int) stored as parquet location 'test_files/scratch/insert/bad_new_empty_table'; -- no trailing slash
346+
347+
# should fail
348+
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
349+
insert into bad_new_empty_table values (1);
350+
351+
statement ok
352+
drop table bad_new_empty_table;

0 commit comments

Comments
 (0)