From 8dc0d0720064a2e7a01a07c4bee765b23a93c5be Mon Sep 17 00:00:00 2001 From: cgardens Date: Wed, 14 Oct 2020 11:12:35 -0700 Subject: [PATCH] fix fields --- .../bigquery/BigQueryDestinationTest.java | 7 ++++--- .../destination/csv/CsvDestinationTest.java | 15 ++++----------- .../postgres/PostgresDestinationTest.java | 5 +++-- .../java/io/airbyte/protocol/models/Field.java | 6 +----- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/airbyte-integrations/bigquery-destination/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryDestinationTest.java b/airbyte-integrations/bigquery-destination/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryDestinationTest.java index 01ef57c3c25fb..a6ffca913edc3 100644 --- a/airbyte-integrations/bigquery-destination/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryDestinationTest.java +++ b/airbyte-integrations/bigquery-destination/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryDestinationTest.java @@ -102,9 +102,10 @@ class BigQueryDestinationTest { .withState(new AirbyteStateMessage().withData(objectMapper.createObjectNode().put("checkpoint", "now!"))); private static final AirbyteCatalog CATALOG = new AirbyteCatalog().withStreams(Lists.newArrayList( - CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, io.airbyte.protocol.models.Field.of("name", "string"), io.airbyte.protocol.models.Field - .of("id", "string")), - CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", "string")))); + CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, io.airbyte.protocol.models.Field.of("name", Field.JsonSchemaPrimitives.STRING), + io.airbyte.protocol.models.Field + .of("id", Field.JsonSchemaPrimitives.STRING)), + CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", Field.JsonSchemaPrimitives.STRING)))); private JsonNode config; diff --git a/airbyte-integrations/csv-destination/src/test/java/io/airbyte/integrations/destination/csv/CsvDestinationTest.java b/airbyte-integrations/csv-destination/src/test/java/io/airbyte/integrations/destination/csv/CsvDestinationTest.java index 257fa671f95da..80d281bf4159b 100644 --- a/airbyte-integrations/csv-destination/src/test/java/io/airbyte/integrations/destination/csv/CsvDestinationTest.java +++ b/airbyte-integrations/csv-destination/src/test/java/io/airbyte/integrations/destination/csv/CsvDestinationTest.java @@ -45,6 +45,7 @@ import io.airbyte.protocol.models.AirbyteStateMessage; import io.airbyte.protocol.models.CatalogHelpers; import io.airbyte.protocol.models.Field; +import io.airbyte.protocol.models.Field.JsonSchemaPrimitives; import java.io.FileReader; import java.io.IOException; import java.io.Reader; @@ -91,17 +92,9 @@ class CsvDestinationTest { .withState(new AirbyteStateMessage().withData(objectMapper.createObjectNode().put("checkpoint", "now!"))); private static final AirbyteCatalog CATALOG = new AirbyteCatalog().withStreams(Lists.newArrayList( - CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, Field.of("name", "string"), Field.of("id", "string")), - CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", "string")))); - // private static final Schema CATALOG = new AirbyteCatalog().withStreams(Lists.newArrayList( - // new AirbyteStream().withName(USERS_STREAM_NAME) - // .withSchema(CatalogHelpers.createAirbyteStream() - // CatalLists.newArrayList(new - // Field().withName("name").withDataType(DataType.STRING).withSelected(true), - // new Field().withName("id").withDataType(DataType.STRING).withSelected(true))), - // new AirbyteStream().withName(TASKS_STREAM_NAME) - // .withFields(Lists.newArrayList(new - // Field().withName("goal").withDataType(DataType.STRING).withSelected(true))))); + CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, Field.of("name", JsonSchemaPrimitives.STRING), + Field.of("id", JsonSchemaPrimitives.STRING)), + CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", JsonSchemaPrimitives.STRING)))); private Path destinationPath; private ObjectNode config; diff --git a/airbyte-integrations/postgres-destination/src/test/java/io/airbyte/integrations/destination/postgres/PostgresDestinationTest.java b/airbyte-integrations/postgres-destination/src/test/java/io/airbyte/integrations/destination/postgres/PostgresDestinationTest.java index cc9423e5ad07d..02741ba690121 100644 --- a/airbyte-integrations/postgres-destination/src/test/java/io/airbyte/integrations/destination/postgres/PostgresDestinationTest.java +++ b/airbyte-integrations/postgres-destination/src/test/java/io/airbyte/integrations/destination/postgres/PostgresDestinationTest.java @@ -93,8 +93,9 @@ class PostgresDestinationTest { .withState(new AirbyteStateMessage().withData(objectMapper.createObjectNode().put("checkpoint", "now!"))); private static final AirbyteCatalog CATALOG = new AirbyteCatalog().withStreams(Lists.newArrayList( - CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, Field.of("name", "string"), Field.of("id", "string")), - CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", "string")))); + CatalogHelpers.createAirbyteStream(USERS_STREAM_NAME, Field.of("name", Field.JsonSchemaPrimitives.STRING), + Field.of("id", Field.JsonSchemaPrimitives.STRING)), + CatalogHelpers.createAirbyteStream(TASKS_STREAM_NAME, Field.of("goal", Field.JsonSchemaPrimitives.STRING)))); private JsonNode config; diff --git a/airbyte-protocol/models/src/main/java/io/airbyte/protocol/models/Field.java b/airbyte-protocol/models/src/main/java/io/airbyte/protocol/models/Field.java index 6b02f7b91befe..40c9389dde8cf 100644 --- a/airbyte-protocol/models/src/main/java/io/airbyte/protocol/models/Field.java +++ b/airbyte-protocol/models/src/main/java/io/airbyte/protocol/models/Field.java @@ -26,7 +26,7 @@ public class Field { - private enum JsonSchemaPrimitives { + public static enum JsonSchemaPrimitives { STRING, NUMBER, OBJECT, @@ -47,10 +47,6 @@ public static Field of(String name, JsonSchemaPrimitives type) { return new Field(name, type); } - public static Field of(String name, String type) { - return new Field(name, JsonSchemaPrimitives.valueOf(type)); - } - public String getName() { return name; }