Skip to content

Commit

Permalink
test: split numeric tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen committed Feb 21, 2024
1 parent 609bae3 commit f2da113
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
12 changes: 6 additions & 6 deletions connector_arrow/src/duckdb/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl SchemaEdit for DuckDBConnection {
fn ty_from_arrow(data_type: &DataType) -> &'static str {
match data_type {
// there is no Null type in DuckDB, so we fallback to some other type that is nullable
DataType::Null => "int64",
DataType::Null => "BIGINT",

DataType::Boolean => "BOOLEAN",
DataType::Int8 => "TINYINT",
Expand All @@ -103,11 +103,11 @@ fn ty_from_arrow(data_type: &DataType) -> &'static str {
DataType::Time64(_) => unimplemented!(),
DataType::Duration(_) => unimplemented!(),
DataType::Interval(_) => unimplemented!(),
DataType::Binary => "blob",
DataType::FixedSizeBinary(_) => "blob",
DataType::LargeBinary => "blob",
DataType::Utf8 => "text",
DataType::LargeUtf8 => "text",
DataType::Binary => "BLOB",
DataType::FixedSizeBinary(_) => "BLOB",
DataType::LargeBinary => "BLOB",
DataType::Utf8 => "VARCHAR",
DataType::LargeUtf8 => "VARCHAR",
DataType::List(_) => unimplemented!(),
DataType::FixedSizeList(_, _) => unimplemented!(),
DataType::LargeList(_) => unimplemented!(),
Expand Down
4 changes: 2 additions & 2 deletions connector_arrow/src/sqlite/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pub fn ty_from_arrow(ty: &DataType) -> &'static str {
DataType::Struct(_) => unimplemented!(),
DataType::Union(_, _) => unimplemented!(),
DataType::Dictionary(_, _) => unimplemented!(),
DataType::Decimal128(_, _) => unimplemented!(),
DataType::Decimal256(_, _) => unimplemented!(),
DataType::Decimal128(_, _) => "TEXT",
DataType::Decimal256(_, _) => "TEXT",
DataType::Map(_, _) => unimplemented!(),
DataType::RunEndEncoded(_, _) => unimplemented!(),
}
Expand Down
26 changes: 20 additions & 6 deletions connector_arrow/tests/it/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,46 @@ pub fn null_bool() -> Vec<ColumnSpec> {
)
}

pub fn numeric() -> Vec<ColumnSpec> {
pub fn int() -> Vec<ColumnSpec> {
domains_to_batch_spec(
&[
DataType::Int8,
DataType::Int16,
DataType::Int32,
DataType::Int64,
],
&[false, true],
&VALUE_GEN_PROCESS_ALL,
)
}

pub fn uint() -> Vec<ColumnSpec> {
domains_to_batch_spec(
&[
DataType::UInt8,
DataType::UInt16,
DataType::UInt32,
// DataType::UInt64,
DataType::Float16,
DataType::Float32,
DataType::Float64,
],
&[false, true],
&VALUE_GEN_PROCESS_ALL,
)
}

pub fn float() -> Vec<ColumnSpec> {
domains_to_batch_spec(
&[DataType::Float16, DataType::Float32, DataType::Float64],
&[false, true],
&VALUE_GEN_PROCESS_ALL,
)
}

pub fn decimal() -> Vec<ColumnSpec> {
domains_to_batch_spec(
&[
DataType::Decimal128(15, 4),
DataType::Decimal128(Decimal128Type::MAX_PRECISION, 0),
DataType::Decimal128(Decimal128Type::MAX_PRECISION, Decimal128Type::MAX_SCALE),
// DataType::Decimal128(Decimal128Type::MAX_PRECISION, 0),
// DataType::Decimal128(Decimal128Type::MAX_PRECISION, Decimal128Type::MAX_SCALE),
DataType::Decimal256(45, 12),
DataType::Decimal256(Decimal256Type::MAX_PRECISION, 0),
DataType::Decimal256(Decimal256Type::MAX_PRECISION, Decimal256Type::MAX_SCALE),
Expand Down
4 changes: 3 additions & 1 deletion connector_arrow/tests/it/test_duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ fn query_01() {
#[rstest]
#[case::empty("roundtrip::empty", spec::empty())]
#[case::null_bool("roundtrip::null_bool", spec::null_bool())]
#[case::numeric("roundtrip::numeric", spec::numeric())]
#[case::int("roundtrip::int", spec::int())]
#[case::uint("roundtrip::uint", spec::uint())]
#[case::float("roundtrip::float", spec::float())]
fn roundtrip(#[case] table_name: &str, #[case] spec: spec::ArrowGenSpec) {
let mut conn = init();
super::tests::roundtrip(&mut conn, table_name, spec);
Expand Down
4 changes: 3 additions & 1 deletion connector_arrow/tests/it/test_postgres_extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ fn query_02() {
#[rstest]
#[case::empty("extended::roundtrip::empty", spec::empty())]
#[case::null_bool("extended::roundtrip::null_bool", spec::null_bool())]
#[case::numeric("extended::roundtrip::numeric", spec::numeric())]
#[case::int("extended::roundtrip::int", spec::int())]
#[case::uint("extended::roundtrip::uint", spec::uint())]
#[case::float("extended::roundtrip::float", spec::float())]
#[case::decimal("extended::roundtrip::decimal", spec::decimal())]
fn roundtrip(#[case] table_name: &str, #[case] spec: spec::ArrowGenSpec) {
let mut conn = init();
Expand Down
4 changes: 3 additions & 1 deletion connector_arrow/tests/it/test_postgres_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ fn query_02() {
#[rstest]
#[case::empty("simple::roundtrip::empty", spec::empty())]
#[case::null_bool("simple::roundtrip::null_bool", spec::null_bool())]
#[case::numeric("simple::roundtrip::numeric", spec::numeric())]
#[case::int("simple::roundtrip::int", spec::int())]
#[case::uint("simple::roundtrip::uint", spec::uint())]
#[case::float("simple::roundtrip::float", spec::float())]
#[case::decimal("simple::roundtrip::decimal", spec::decimal())]
fn roundtrip(#[case] table_name: &str, #[case] spec: spec::ArrowGenSpec) {
let mut conn = init();
Expand Down
4 changes: 3 additions & 1 deletion connector_arrow/tests/it/test_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ fn query_01() {
#[rstest]
// #[case::empty("roundtrip::empty", spec::empty())]
#[case::null_bool("roundtrip::null_bool", spec::null_bool())]
#[case::numeric("roundtrip::numeric", spec::numeric())]
#[case::int("roundtrip::int", spec::int())]
#[case::uint("roundtrip::uint", spec::uint())]
#[case::float("roundtrip::float", spec::float())]
fn roundtrip(#[case] table_name: &str, #[case] spec: spec::ArrowGenSpec) {
let mut conn = init();
super::tests::roundtrip(&mut conn, table_name, spec);
Expand Down

0 comments on commit f2da113

Please sign in to comment.