Changeset: 71f3eba34a1b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/71f3eba34a1b
Added Files:
        sql/test/file_loader/Tests/cars.csv
        sql/test/file_loader/Tests/cars.psv
        sql/test/file_loader/Tests/cars.tsv
        sql/test/file_loader/Tests/cars_semicolon.csv
        sql/test/file_loader/Tests/file_loader_field_separator.test.in
Modified Files:
        sql/test/file_loader/Tests/All
Branch: default
Log Message:

Adding data files with different field separators and extensions, and test to 
read those data files.
Currently the file_loader fails to recognise the field separator correctly. 
Also it does not recognise .tsv or .psv extensions.


diffs (199 lines):

diff --git a/sql/test/file_loader/Tests/All b/sql/test/file_loader/Tests/All
--- a/sql/test/file_loader/Tests/All
+++ b/sql/test/file_loader/Tests/All
@@ -1,2 +1,3 @@
 file_loader_function
 file_loader_string
+file_loader_field_separator
diff --git a/sql/test/file_loader/Tests/cars.csv 
b/sql/test/file_loader/Tests/cars.csv
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/cars.csv
@@ -0,0 +1,4 @@
+2000,"Ford","Focus",1994
+2001,"Honda",,
+2004,"Tesla","S3XY",2019
+2014,"Lightyear","0",2022
diff --git a/sql/test/file_loader/Tests/cars.psv 
b/sql/test/file_loader/Tests/cars.psv
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/cars.psv
@@ -0,0 +1,4 @@
+2000|"Ford"|"Focus"|1994
+2001|"Honda"||
+2004|"Tesla"|"S3XY"|2019
+2014|"Lightyear"|"0"|2022
diff --git a/sql/test/file_loader/Tests/cars.tsv 
b/sql/test/file_loader/Tests/cars.tsv
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/cars.tsv
@@ -0,0 +1,4 @@
+2000   "Ford"  "Focus" 1994
+2001   "Honda"         
+2004   "Tesla" "S3XY"  2019
+2014   "Lightyear"     "0"     2022
diff --git a/sql/test/file_loader/Tests/cars_semicolon.csv 
b/sql/test/file_loader/Tests/cars_semicolon.csv
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/cars_semicolon.csv
@@ -0,0 +1,4 @@
+2000;"Ford";"Focus";1994
+2001;"Honda";;
+2004;"Tesla";"S3XY";2019
+2014;"Lightyear";"0";2022
diff --git a/sql/test/file_loader/Tests/file_loader_field_separator.test.in 
b/sql/test/file_loader/Tests/file_loader_field_separator.test.in
new file mode 100644
--- /dev/null
+++ b/sql/test/file_loader/Tests/file_loader_field_separator.test.in
@@ -0,0 +1,151 @@
+# tests to load cars (4 columns, 4 rows) data files with different field 
separators: comma , (.csv), pipe | (.psv), tab (.tsv), semicolon ; (.csv)
+
+## next query incorrectly returns error: received 1 columns, expected 4 columns
+query ITTI
+select * from '$QTSTSRCDIR/cars.csv'
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
+## next query incorrectly returns all columns as 1 column data. Should error: 
received 4 columns, expected 1 columns
+query T
+select * from '$QTSTSRCDIR/cars.csv'
+----
+2000,"Ford","Focus",1994
+2001,"Honda",,
+2004,"Tesla","S3XY",2019
+2014,"Lightyear","0",2022
+
+
+## next query incorrectly returns error: received 1 columns, expected 4 columns
+query ITTI
+select * from file_loader(r'$QTSTSRCDIR/cars.csv')
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
+statement error 42000!syntax error, unexpected YEAR in: "select * from 
file_loader(...
+select * from file_loader(R'$QTSTSRCDIR/cars.csv') file(id, brand, model, year)
+----
+
+## next query incorrectly returns error: 42000!SELECT: The number of aliases 
don't match the number of columns (4 != 1)
+query ITTI
+select * from file_loader(r'$QTSTSRCDIR/cars.csv') as cars(id, brand, model, 
"year")
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
+## next query incorrectly returns all columns as 1 column data. Should error: 
received 4 columns, expected 1 columns
+query T
+select * from file_loader('$QTSTSRCDIR/cars.csv') cars(cols)
+----
+2000,"Ford","Focus",1994
+2001,"Honda",,
+2004,"Tesla","S3XY",2019
+2014,"Lightyear","0",2022
+
+## next query incorrectly returns error: 42000!SELECT: file_loader function 
failed 'Filename extension 'psv' missing'
+query ITTI
+select * from file_loader(r'$QTSTSRCDIR/cars.psv') as cars(id, brand, model, 
"year")
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
+## next query incorrectly returns error: 42000!SELECT: file_loader function 
failed 'Filename extension 'tsv' missing'
+query ITTI
+select * from file_loader(r'$QTSTSRCDIR/cars.tsv') as cars(id, brand, model, 
"year")
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
+## next query incorrectly returns error: 42000!SELECT: The number of aliases 
don't match the number of columns (4 != 1)
+query ITTI
+select * from file_loader(r'$QTSTSRCDIR/cars_semicolon.csv') as cars(id, 
brand, model, "year")
+----
+2000
+Ford
+Focus
+1994
+2001
+Honda
+NULL
+NULL
+2004
+Tesla
+S3XY
+2019
+2014
+Lightyear
+0
+2022
+
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to