Skip to content

Commit 3528645

Browse files
committed
google format
1 parent de01d68 commit 3528645

File tree

2 files changed

+79
-64
lines changed

2 files changed

+79
-64
lines changed

airbyte-integrations/connectors/destination-bigquery-denormalized/src/test-integration/java/io/airbyte/integrations/destination/bigquery/BigQueryDenormalizedDestinationAcceptanceTest.java

+36-20
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@
99
import com.fasterxml.jackson.databind.JsonNode;
1010
import com.fasterxml.jackson.databind.node.ObjectNode;
1111
import com.google.auth.oauth2.ServiceAccountCredentials;
12-
import com.google.cloud.bigquery.*;
12+
import com.google.cloud.bigquery.BigQuery;
13+
import com.google.cloud.bigquery.BigQueryOptions;
14+
import com.google.cloud.bigquery.ConnectionProperty;
15+
import com.google.cloud.bigquery.Dataset;
16+
import com.google.cloud.bigquery.DatasetInfo;
17+
import com.google.cloud.bigquery.Field;
18+
import com.google.cloud.bigquery.FieldList;
19+
import com.google.cloud.bigquery.FieldValue;
20+
import com.google.cloud.bigquery.FieldValueList;
21+
import com.google.cloud.bigquery.Job;
22+
import com.google.cloud.bigquery.JobId;
23+
import com.google.cloud.bigquery.JobInfo;
24+
import com.google.cloud.bigquery.QueryJobConfiguration;
25+
import com.google.cloud.bigquery.TableResult;
1326
import com.google.common.collect.ImmutableMap;
14-
import io.airbyte.db.bigquery.BigQueryResultSet;
15-
import io.airbyte.db.bigquery.BigQuerySourceOperations;
1627
import com.google.common.collect.Streams;
1728
import io.airbyte.commons.json.Jsons;
1829
import io.airbyte.commons.resources.MoreResources;
1930
import io.airbyte.commons.string.Strings;
31+
import io.airbyte.db.bigquery.BigQueryResultSet;
32+
import io.airbyte.db.bigquery.BigQuerySourceOperations;
2033
import io.airbyte.integrations.base.JavaBaseConstants;
2134
import io.airbyte.integrations.destination.NamingConventionTransformer;
2235
import io.airbyte.integrations.destination.StandardNameTransformer;
@@ -33,7 +46,11 @@
3346
import java.nio.charset.StandardCharsets;
3447
import java.nio.file.Files;
3548
import java.nio.file.Path;
36-
import java.util.*;
49+
import java.util.Collections;
50+
import java.util.List;
51+
import java.util.Optional;
52+
import java.util.TimeZone;
53+
import java.util.UUID;
3754
import java.util.stream.Collectors;
3855
import org.apache.commons.lang3.tuple.ImmutablePair;
3956
import org.junit.jupiter.params.ParameterizedTest;
@@ -118,8 +135,8 @@ protected boolean supportObjectDataTypeTest() {
118135

119136
@Override
120137
protected void assertNamespaceNormalization(final String testCaseId,
121-
final String expectedNormalizedNamespace,
122-
final String actualNormalizedNamespace) {
138+
final String expectedNormalizedNamespace,
139+
final String actualNormalizedNamespace) {
123140
final String message = String.format("Test case %s failed; if this is expected, please override assertNamespaceNormalization", testCaseId);
124141
if (testCaseId.equals("S3A-1")) {
125142
// bigquery allows namespace starting with a number, and prepending underscore
@@ -145,10 +162,10 @@ protected List<JsonNode> retrieveNormalizedRecords(final TestDestinationEnv test
145162

146163
@Override
147164
protected List<JsonNode> retrieveRecords(final TestDestinationEnv env,
148-
final String streamName,
149-
final String namespace,
150-
final JsonNode streamSchema)
151-
throws Exception {
165+
final String streamName,
166+
final String namespace,
167+
final JsonNode streamSchema)
168+
throws Exception {
152169
final String tableName = namingResolver.getIdentifier(streamName);
153170
final String schema = namingResolver.getIdentifier(namespace);
154171
return retrieveRecordsFromTable(tableName, schema);
@@ -158,20 +175,20 @@ private List<JsonNode> retrieveRecordsFromTable(final String tableName, final St
158175
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
159176

160177
final QueryJobConfiguration queryConfig =
161-
QueryJobConfiguration
162-
.newBuilder(
163-
String.format("SELECT * FROM `%s`.`%s` order by %s asc;", schema, tableName,
164-
JavaBaseConstants.COLUMN_NAME_EMITTED_AT))
178+
QueryJobConfiguration
179+
.newBuilder(
180+
String.format("SELECT * FROM `%s`.`%s` order by %s asc;", schema, tableName,
181+
JavaBaseConstants.COLUMN_NAME_EMITTED_AT))
165182
// .setUseLegacySql(false)
166-
.setConnectionProperties(Collections.singletonList(ConnectionProperty.of("time_zone", "UTC")))
167-
.build();
183+
.setConnectionProperties(Collections.singletonList(ConnectionProperty.of("time_zone", "UTC")))
184+
.build();
168185

169186
final TableResult queryResults = executeQuery(bigquery, queryConfig).getLeft().getQueryResults();
170187
final FieldList fields = queryResults.getSchema().getFields();
171188
BigQuerySourceOperations sourceOperations = new BigQuerySourceOperations();
172189

173190
return Streams.stream(queryResults.iterateAll())
174-
.map(fieldValues -> sourceOperations.rowToJson(new BigQueryResultSet(fieldValues, fields))).collect(Collectors.toList());
191+
.map(fieldValues -> sourceOperations.rowToJson(new BigQueryResultSet(fieldValues, fields))).collect(Collectors.toList());
175192
}
176193

177194
private boolean isAirbyteColumn(final String name) {
@@ -294,9 +311,8 @@ private static Job waitForQuery(final Job queryJob) {
294311
}
295312

296313
/**
297-
* Verify that the integration successfully writes normalized records successfully (without actually
298-
* running the normalization module) Tests a wide variety of messages an schemas (aspirationally,
299-
* anyway).
314+
* Verify that the integration successfully writes normalized records successfully (without actually running the normalization module) Tests a wide
315+
* variety of messages an schemas (aspirationally, anyway).
300316
*/
301317
@ParameterizedTest
302318
@ArgumentsSource(DataArgumentsProvider.class)

airbyte-integrations/connectors/destination-bigquery-denormalized/src/test-integration/java/io/airbyte/integrations/destination/bigquery/BigQueryDenormalizedTestDataComparator.java

+43-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.airbyte.integrations.destination.StandardNameTransformer;
44
import io.airbyte.integrations.standardtest.destination.comparator.AdvancedTestDataComparator;
5-
65
import java.time.LocalDate;
76
import java.time.LocalDateTime;
87
import java.time.ZoneOffset;
@@ -13,58 +12,58 @@
1312

1413
public class BigQueryDenormalizedTestDataComparator extends AdvancedTestDataComparator {
1514

16-
private static final String BIGQUERY_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
15+
private static final String BIGQUERY_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
1716

18-
private final StandardNameTransformer namingResolver = new StandardNameTransformer();
17+
private final StandardNameTransformer namingResolver = new StandardNameTransformer();
1918

20-
@Override
21-
protected List<String> resolveIdentifier(final String identifier) {
22-
final List<String> result = new ArrayList<>();
23-
result.add(identifier);
24-
result.add(namingResolver.getIdentifier(identifier));
25-
return result;
26-
}
19+
@Override
20+
protected List<String> resolveIdentifier(final String identifier) {
21+
final List<String> result = new ArrayList<>();
22+
result.add(identifier);
23+
result.add(namingResolver.getIdentifier(identifier));
24+
return result;
25+
}
2726

28-
private LocalDate parseDate(String dateValue) {
29-
if (dateValue != null) {
30-
var format = (dateValue.matches(".+Z") ? BIGQUERY_DATETIME_FORMAT : AIRBYTE_DATE_FORMAT);
31-
return LocalDate.parse(dateValue, DateTimeFormatter.ofPattern(format));
32-
} else {
33-
return null;
34-
}
27+
private LocalDate parseDate(String dateValue) {
28+
if (dateValue != null) {
29+
var format = (dateValue.matches(".+Z") ? BIGQUERY_DATETIME_FORMAT : AIRBYTE_DATE_FORMAT);
30+
return LocalDate.parse(dateValue, DateTimeFormatter.ofPattern(format));
31+
} else {
32+
return null;
3533
}
34+
}
3635

37-
private LocalDateTime parseDateTime(String dateTimeValue) {
38-
if (dateTimeValue != null) {
39-
var format = (dateTimeValue.matches(".+Z") ? BIGQUERY_DATETIME_FORMAT : AIRBYTE_DATETIME_FORMAT);
40-
return LocalDateTime.parse(dateTimeValue, DateTimeFormatter.ofPattern(format));
41-
} else {
42-
return null;
43-
}
36+
private LocalDateTime parseDateTime(String dateTimeValue) {
37+
if (dateTimeValue != null) {
38+
var format = (dateTimeValue.matches(".+Z") ? BIGQUERY_DATETIME_FORMAT : AIRBYTE_DATETIME_FORMAT);
39+
return LocalDateTime.parse(dateTimeValue, DateTimeFormatter.ofPattern(format));
40+
} else {
41+
return null;
4442
}
43+
}
4544

46-
@Override
47-
protected boolean compareDateTimeValues(String expectedValue, String actualValue) {
48-
var destinationDate = parseDateTime(actualValue);
49-
var expectedDate = LocalDateTime.parse(expectedValue, DateTimeFormatter.ofPattern(AIRBYTE_DATETIME_FORMAT));
50-
return expectedDate.equals(destinationDate);
51-
}
45+
@Override
46+
protected boolean compareDateTimeValues(String expectedValue, String actualValue) {
47+
var destinationDate = parseDateTime(actualValue);
48+
var expectedDate = LocalDateTime.parse(expectedValue, DateTimeFormatter.ofPattern(AIRBYTE_DATETIME_FORMAT));
49+
return expectedDate.equals(destinationDate);
50+
}
5251

53-
@Override
54-
protected boolean compareDateValues(String expectedValue, String actualValue) {
55-
var destinationDate = parseDate(actualValue);
56-
var expectedDate = LocalDate.parse(expectedValue, DateTimeFormatter.ofPattern(AIRBYTE_DATE_FORMAT));
57-
return expectedDate.equals(destinationDate);
58-
}
52+
@Override
53+
protected boolean compareDateValues(String expectedValue, String actualValue) {
54+
var destinationDate = parseDate(actualValue);
55+
var expectedDate = LocalDate.parse(expectedValue, DateTimeFormatter.ofPattern(AIRBYTE_DATE_FORMAT));
56+
return expectedDate.equals(destinationDate);
57+
}
5958

60-
@Override
61-
protected ZonedDateTime parseDestinationDateWithTz(String destinationValue) {
62-
return ZonedDateTime.of(LocalDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(BIGQUERY_DATETIME_FORMAT)), ZoneOffset.UTC);
63-
}
59+
@Override
60+
protected ZonedDateTime parseDestinationDateWithTz(String destinationValue) {
61+
return ZonedDateTime.of(LocalDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(BIGQUERY_DATETIME_FORMAT)), ZoneOffset.UTC);
62+
}
6463

65-
@Override
66-
protected boolean compareDateTimeWithTzValues(String airbyteMessageValue, String destinationValue) {
67-
return super.compareDateTimeWithTzValues(airbyteMessageValue, destinationValue);
68-
}
64+
@Override
65+
protected boolean compareDateTimeWithTzValues(String airbyteMessageValue, String destinationValue) {
66+
return super.compareDateTimeWithTzValues(airbyteMessageValue, destinationValue);
67+
}
6968

7069
}

0 commit comments

Comments
 (0)