ahmedabu98 commented on code in PR #25685:
URL: https://github.com/apache/beam/pull/25685#discussion_r1125781060
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryStorageWriteApiSchemaTransformProviderTest.java:
##########
@@ -102,53 +120,61 @@ public void testInvalidConfig() {
public PCollectionRowTuple runWithConfig(
BigQueryStorageWriteApiSchemaTransformConfiguration config) {
+ return runWithConfig(config, ROWS);
+ }
+
+ public PCollectionRowTuple runWithConfig(
+ BigQueryStorageWriteApiSchemaTransformConfiguration config, List<Row>
inputRows) {
BigQueryStorageWriteApiSchemaTransformProvider provider =
new BigQueryStorageWriteApiSchemaTransformProvider();
BigQueryStorageWriteApiPCollectionRowTupleTransform writeRowTupleTransform
=
(BigQueryStorageWriteApiPCollectionRowTupleTransform)
provider.from(config).buildTransform();
- List<Row> testRows =
- Arrays.asList(
- Row.withSchema(SCHEMA)
- .withFieldValue("name", "a")
- .withFieldValue("number", 1L)
- .withFieldValue("dt",
LocalDateTime.parse("2000-01-01T00:00:00"))
- .build(),
- Row.withSchema(SCHEMA)
- .withFieldValue("name", "b")
- .withFieldValue("number", 2L)
- .withFieldValue("dt",
LocalDateTime.parse("2000-01-02T00:00:00"))
- .build(),
- Row.withSchema(SCHEMA)
- .withFieldValue("name", "c")
- .withFieldValue("number", 3L)
- .withFieldValue("dt",
LocalDateTime.parse("2000-01-03T00:00:00"))
- .build());
-
writeRowTupleTransform.setBigQueryServices(fakeBigQueryServices);
String tag = provider.inputCollectionNames().get(0);
- PCollection<Row> rows = p.apply(Create.of(testRows).withRowSchema(SCHEMA));
+ PCollection<Row> rows =
p.apply(Create.of(inputRows).withRowSchema(SCHEMA));
PCollectionRowTuple input = PCollectionRowTuple.of(tag, rows);
PCollectionRowTuple result = input.apply(writeRowTupleTransform);
return result;
}
+ public Boolean rowsEquals(List<Row> expectedRows, List<TableRow> actualRows)
{
+ if (expectedRows.size() != actualRows.size()) {
+ return false;
+ }
+ for (int i = 0; i < expectedRows.size(); i++) {
+ // Actual rows may come back disordered. For each TableRow, find its
"number" column value
Review Comment:
Yup, changing to that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]