Skip to content

Commit

Permalink
add and improve test for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Jun 13, 2024
1 parent 47f10b0 commit 3add7a4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/quack_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,7 @@ ConvertPostgresToDuckValue(Datum value, duckdb::Vector &result, idx_t offset) {
auto previous_dimension = dim ? dims[dim - 1] : 1;
auto dimension = dims[dim];
if (vec->GetType().id() != duckdb::LogicalTypeId::LIST) {
// TODO: provide a more detailed description of the error
elog(ERROR, "Dimensionality of the schema and the data does not match");
elog(ERROR, "Dimensionality of the schema and the data does not match, data contains more dimensions than the amount of dimensions specified by the schema");
}
auto child_offset = duckdb::ListVector::GetListSize(*vec);
auto list_data = duckdb::FlatVector::GetData<duckdb::list_entry_t>(*vec);
Expand All @@ -809,9 +808,7 @@ ConvertPostgresToDuckValue(Datum value, duckdb::Vector &result, idx_t offset) {
}

if (vec->GetType().id() == duckdb::LogicalTypeId::LIST) {
// Same as before, but now the data has fewer dimensions than the schema
// TODO: provide a more detailed description of the error
elog(ERROR, "Dimensionality of the schema and the data does not match");
elog(ERROR, "Dimensionality of the schema and the data does not match, data contains fewer dimensions than the amount of dimensions specified by the schema");
}

auto child_type = vec->GetType();
Expand Down
12 changes: 11 additions & 1 deletion test/regression/expected/array_type_support.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ INSERT INTO int_array_2d VALUES
('{{11, 12, 13}, {14, 15, 16}}'),
('{{17, 18}, {19, 20}}');
SELECT * FROM int_array_2d;
ERROR: Dimensionality of the schema and the data does not match
ERROR: Dimensionality of the schema and the data does not match, data contains more dimensions than the amount of dimensions specified by the schema
drop table int_array_2d;
-- INT4 (single dimensional data, two dimensionsal type)
CREATE TABLE int_array_2d(a INT[][]);
INSERT INTO int_array_2d VALUES
('{1, 2}'),
('{5, 6, 7}'),
('{11, 12, 13}'),
('{17, 18}');
SELECT * FROM int_array_2d;
ERROR: Dimensionality of the schema and the data does not match, data contains fewer dimensions than the amount of dimensions specified by the schema
drop table int_array_2d;
-- INT4 (two dimensional data and type)
CREATE TABLE int_array_2d(a INT[][]);
Expand Down
10 changes: 10 additions & 0 deletions test/regression/sql/array_type_support.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ INSERT INTO int_array_2d VALUES
SELECT * FROM int_array_2d;
drop table int_array_2d;

-- INT4 (single dimensional data, two dimensionsal type)
CREATE TABLE int_array_2d(a INT[][]);
INSERT INTO int_array_2d VALUES
('{1, 2}'),
('{5, 6, 7}'),
('{11, 12, 13}'),
('{17, 18}');
SELECT * FROM int_array_2d;
drop table int_array_2d;

-- INT4 (two dimensional data and type)
CREATE TABLE int_array_2d(a INT[][]);
INSERT INTO int_array_2d VALUES
Expand Down

0 comments on commit 3add7a4

Please sign in to comment.