From 3add7a42ae0a85a94ff189dcfc6b197e03b6e2f5 Mon Sep 17 00:00:00 2001 From: Tishj Date: Thu, 13 Jun 2024 11:29:03 +0200 Subject: [PATCH] add and improve test for errors --- src/quack_types.cpp | 7 ++----- test/regression/expected/array_type_support.out | 12 +++++++++++- test/regression/sql/array_type_support.sql | 10 ++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/quack_types.cpp b/src/quack_types.cpp index 6dd57952..0a03b0b2 100644 --- a/src/quack_types.cpp +++ b/src/quack_types.cpp @@ -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(*vec); @@ -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(); diff --git a/test/regression/expected/array_type_support.out b/test/regression/expected/array_type_support.out index e4a91438..cdeb6222 100644 --- a/test/regression/expected/array_type_support.out +++ b/test/regression/expected/array_type_support.out @@ -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[][]); diff --git a/test/regression/sql/array_type_support.sql b/test/regression/sql/array_type_support.sql index ca938c64..9bd247fa 100644 --- a/test/regression/sql/array_type_support.sql +++ b/test/regression/sql/array_type_support.sql @@ -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