From 79080c88f59e21968eb7d246ec86dc1426545d15 Mon Sep 17 00:00:00 2001 From: Rodi Reich Zilberman <867491+rodireich@users.noreply.github.com> Date: Wed, 11 Oct 2023 08:23:50 -0700 Subject: [PATCH] Update tests to current Jackson lib behavior (#31197) Co-authored-by: rodireich --- .../AbstractMySqlSourceDatatypeTest.java | 25 +++--- .../CdcBinlogsMySqlSourceDatatypeTest.java | 12 +++ .../AbstractPostgresSourceDatatypeTest.java | 77 ++++++++++--------- .../CdcWalLogsPostgresSourceDatatypeTest.java | 32 ++++++++ 4 files changed, 98 insertions(+), 48 deletions(-) diff --git a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractMySqlSourceDatatypeTest.java b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractMySqlSourceDatatypeTest.java index 271d2e2fb8c8..1ea69c06ccec 100644 --- a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractMySqlSourceDatatypeTest.java +++ b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractMySqlSourceDatatypeTest.java @@ -232,22 +232,13 @@ protected void initTests() { .addExpectedValues("0.188", null) .build()); - addDataTypeTestData( - TestDataHolder.builder() - .sourceType("decimal") - .airbyteType(JsonSchemaType.NUMBER) - .fullSourceDataType("decimal(19,2)") - .addInsertValues("1700000.01") - .addExpectedValues("1700000.01") - .build()); - addDataTypeTestData( TestDataHolder.builder() .sourceType("decimal") .airbyteType(JsonSchemaType.INTEGER) .fullSourceDataType("decimal(32,0)") - .addInsertValues("1700000.01") - .addExpectedValues("1700000") + .addInsertValues("1700000.01", "123") + .addExpectedValues("1700000", "123") .build()); for (final String type : Set.of("date", "date not null default '0000-00-00'")) { @@ -451,6 +442,7 @@ protected void initTests() { .addExpectedValues(null, "xs,s", "m,xl") .build()); + addDecimalValuesTest(); } protected void addJsonDataTypeTest() { @@ -492,4 +484,15 @@ private String getFileDataInBase64() { return null; } + protected void addDecimalValuesTest() { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType("decimal") + .airbyteType(JsonSchemaType.NUMBER) + .fullSourceDataType("decimal(19,2)") + .addInsertValues("1700000.01", "'123'") + .addExpectedValues("1700000.01", "123.0") + .build()); + } + } diff --git a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcBinlogsMySqlSourceDatatypeTest.java b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcBinlogsMySqlSourceDatatypeTest.java index 522177b2b6be..1dc469ed3b60 100644 --- a/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcBinlogsMySqlSourceDatatypeTest.java +++ b/airbyte-integrations/connectors/source-mysql/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcBinlogsMySqlSourceDatatypeTest.java @@ -181,4 +181,16 @@ protected void addJsonDataTypeTest() { .build()); } + @Override + protected void addDecimalValuesTest() { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType("decimal") + .airbyteType(JsonSchemaType.NUMBER) + .fullSourceDataType("decimal(19,2)") + .addInsertValues("1700000.01", "'123'") + .addExpectedValues("1700000.01", "123.00") + .build()); + } + } diff --git a/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractPostgresSourceDatatypeTest.java b/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractPostgresSourceDatatypeTest.java index 8389fe6ffdff..3c127adb1c08 100644 --- a/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractPostgresSourceDatatypeTest.java +++ b/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/AbstractPostgresSourceDatatypeTest.java @@ -202,20 +202,6 @@ protected void initTests() { .addExpectedValues((String) null) .build()); - for (final String type : Set.of("double precision", "float", "float8")) { - addDataTypeTestData( - TestDataHolder.builder() - .sourceType(type) - .airbyteType(JsonSchemaType.NUMBER) - .addInsertValues("'123'", "'1234567890.1234567'", "null") - // Postgres source does not support these special values yet - // https://github.com/airbytehq/airbyte/issues/8902 - // "'-Infinity'", "'Infinity'", "'NaN'", "null") - .addExpectedValues("123.0", "1.2345678901234567E9", null) - // "-Infinity", "Infinity", "NaN", null) - .build()); - } - addDataTypeTestData( TestDataHolder.builder() .sourceType("inet") @@ -320,38 +306,23 @@ protected void initTests() { addDataTypeTestData( TestDataHolder.builder() .sourceType("numeric") - .fullSourceDataType("NUMERIC(38)") + .fullSourceDataType("NUMERIC(38,0)") .airbyteType(JsonSchemaType.INTEGER) - .addInsertValues("'33'") - .addExpectedValues("33") - .build()); - - addDataTypeTestData( - TestDataHolder.builder() - .sourceType("numeric") - .fullSourceDataType("NUMERIC(28,2)") - .airbyteType(JsonSchemaType.NUMBER) - .addInsertValues( - "'123'", "null", "'14525.22'") - // Postgres source does not support these special values yet - // https://github.com/airbytehq/airbyte/issues/8902 - // "'infinity'", "'-infinity'", "'nan'" - .addExpectedValues("123", null, "14525.22") + .addInsertValues("'33'", "'123'") + .addExpectedValues("33", "123") .build()); - // Blocked by https://github.com/airbytehq/airbyte/issues/8902 - for (final String type : Set.of("numeric", "decimal")) { + for (final String type : Set.of("double precision", "float", "float8")) { addDataTypeTestData( TestDataHolder.builder() .sourceType(type) - .fullSourceDataType("NUMERIC(20,7)") .airbyteType(JsonSchemaType.NUMBER) - .addInsertValues( - "'123'", "null", "'1234567890.1234567'") + .addInsertValues("'123'", "'1234567890.1234567'", "null") // Postgres source does not support these special values yet // https://github.com/airbytehq/airbyte/issues/8902 - // "'infinity'", "'-infinity'", "'nan'" - .addExpectedValues("123", null, "1.2345678901234567E9") + // "'-Infinity'", "'Infinity'", "'NaN'", "null") + .addExpectedValues("123.0", "1.2345678901234567E9", null) + // "-Infinity", "Infinity", "NaN", null) .build()); } @@ -592,6 +563,7 @@ protected void initTests() { addTimeWithTimeZoneTest(); addArraysTestData(); addMoneyTest(); + addNumericValuesTest(); } protected void addHstoreTest() { @@ -966,4 +938,35 @@ private void addArraysTestData() { .build()); } + protected void addNumericValuesTest() { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType("numeric") + .fullSourceDataType("NUMERIC(28,2)") + .airbyteType(JsonSchemaType.NUMBER) + .addInsertValues( + "'123'", "null", "'14525.22'") + // Postgres source does not support these special values yet + // https://github.com/airbytehq/airbyte/issues/8902 + // "'infinity'", "'-infinity'", "'nan'" + .addExpectedValues("123.0", null, "14525.22") + .build()); + + // Blocked by https://github.com/airbytehq/airbyte/issues/8902 + for (final String type : Set.of("numeric", "decimal")) { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType(type) + .fullSourceDataType("NUMERIC(20,7)") + .airbyteType(JsonSchemaType.NUMBER) + .addInsertValues( + "'123'", "null", "'1234567890.1234567'") + // Postgres source does not support these special values yet + // https://github.com/airbytehq/airbyte/issues/8902 + // "'infinity'", "'-infinity'", "'nan'" + .addExpectedValues("123.0", null, "1.2345678901234567E9") + .build()); + } + } + } diff --git a/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcWalLogsPostgresSourceDatatypeTest.java b/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcWalLogsPostgresSourceDatatypeTest.java index 65fd35fe0cd6..8a28044a0035 100644 --- a/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcWalLogsPostgresSourceDatatypeTest.java +++ b/airbyte-integrations/connectors/source-postgres/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/CdcWalLogsPostgresSourceDatatypeTest.java @@ -215,4 +215,36 @@ protected void addTimestampWithInfinityValuesTest() { } } + @Override + protected void addNumericValuesTest() { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType("numeric") + .fullSourceDataType("NUMERIC(28,2)") + .airbyteType(JsonSchemaType.NUMBER) + .addInsertValues( + "'123'", "null", "'14525.22'") + // Postgres source does not support these special values yet + // https://github.com/airbytehq/airbyte/issues/8902 + // "'infinity'", "'-infinity'", "'nan'" + .addExpectedValues("123", null, "14525.22") + .build()); + + // Blocked by https://github.com/airbytehq/airbyte/issues/8902 + for (final String type : Set.of("numeric", "decimal")) { + addDataTypeTestData( + TestDataHolder.builder() + .sourceType(type) + .fullSourceDataType("NUMERIC(20,7)") + .airbyteType(JsonSchemaType.NUMBER) + .addInsertValues( + "'123'", "null", "'1234567890.1234567'") + // Postgres source does not support these special values yet + // https://github.com/airbytehq/airbyte/issues/8902 + // "'infinity'", "'-infinity'", "'nan'" + .addExpectedValues("123", null, "1.2345678901234567E9") + .build()); + } + } + }