Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ public static class LoadStatistics extends JobStatistics {
private final Long inputFiles;
private final Long outputBytes;
private final Long outputRows;
private final Long badRecords;

static final class Builder extends JobStatistics.Builder<LoadStatistics, Builder> {

private Long inputBytes;
private Long inputFiles;
private Long outputBytes;
private Long outputRows;
private Long badRecords;

private Builder() {}

Expand All @@ -192,6 +194,7 @@ private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsP
this.inputFiles = statisticsPb.getLoad().getInputFiles();
this.outputBytes = statisticsPb.getLoad().getOutputBytes();
this.outputRows = statisticsPb.getLoad().getOutputRows();
this.badRecords = statisticsPb.getLoad().getBadRecords();
}
}

Expand All @@ -215,6 +218,11 @@ Builder setOutputRows(Long outputRows) {
return self();
}

Builder setBadRecords(Long badRecords) {
this.badRecords = badRecords;
return self();
}

@Override
LoadStatistics build() {
return new LoadStatistics(this);
Expand All @@ -227,6 +235,7 @@ private LoadStatistics(Builder builder) {
this.inputFiles = builder.inputFiles;
this.outputBytes = builder.outputBytes;
this.outputRows = builder.outputRows;
this.badRecords = builder.badRecords;
}

/** Returns the number of bytes of source data in a load job. */
Expand All @@ -249,13 +258,19 @@ public Long getOutputRows() {
return outputRows;
}

/** Returns the number of bad records reported in a job. */
public Long getBadRecords() {
return badRecords;
}

@Override
ToStringHelper toStringHelper() {
return super.toStringHelper()
.add("inputBytes", inputBytes)
.add("inputFiles", inputFiles)
.add("outputBytes", outputBytes)
.add("outputRows", outputRows);
.add("outputRows", outputRows)
.add("badRecords", badRecords);
}

@Override
Expand All @@ -268,7 +283,8 @@ public final boolean equals(Object obj) {

@Override
public final int hashCode() {
return Objects.hash(baseHashCode(), inputBytes, inputFiles, outputBytes, outputRows);
return Objects.hash(
baseHashCode(), inputBytes, inputFiles, outputBytes, outputRows, badRecords);
}

@Override
Expand All @@ -278,6 +294,7 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
loadStatisticsPb.setInputFiles(inputFiles);
loadStatisticsPb.setOutputBytes(outputBytes);
loadStatisticsPb.setOutputRows(outputRows);
loadStatisticsPb.setBadRecords(badRecords);
return super.toPb().setLoad(loadStatisticsPb);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class JobStatisticsTest {
private static final Long INPUT_FILES = 2L;
private static final Long OUTPUT_BYTES = 3L;
private static final Long OUTPUT_ROWS = 4L;
private static final Long BAD_RECORDS = 1L;
private static final List<TableId> REFERENCED_TABLES =
ImmutableList.of(TableId.of("foo", "bar", "table1"), TableId.of("foo", "bar", "table2"));
private static final List<Long> FILE_COUNT = ImmutableList.of(1L, 2L, 3L);
Expand Down Expand Up @@ -74,6 +75,7 @@ public class JobStatisticsTest {
.setInputFiles(INPUT_FILES)
.setOutputBytes(OUTPUT_BYTES)
.setOutputRows(OUTPUT_ROWS)
.setBadRecords(BAD_RECORDS)
.build();
private static final LoadStatistics LOAD_STATISTICS_INCOMPLETE =
LoadStatistics.newBuilder()
Expand All @@ -82,6 +84,7 @@ public class JobStatisticsTest {
.setStartTime(START_TIME)
.setInputBytes(INPUT_BYTES)
.setInputFiles(INPUT_FILES)
.setBadRecords(BAD_RECORDS)
.build();
private static final List<String> SUBSTEPS1 = ImmutableList.of("substep1", "substep2");
private static final List<String> SUBSTEPS2 = ImmutableList.of("substep3", "substep4");
Expand Down Expand Up @@ -168,6 +171,7 @@ public void testBuilder() {
assertEquals(INPUT_FILES, LOAD_STATISTICS.getInputFiles());
assertEquals(OUTPUT_BYTES, LOAD_STATISTICS.getOutputBytes());
assertEquals(OUTPUT_ROWS, LOAD_STATISTICS.getOutputRows());
assertEquals(BAD_RECORDS, LOAD_STATISTICS.getBadRecords());

assertEquals(CREATION_TIME, QUERY_STATISTICS.getCreationTime());
assertEquals(START_TIME, QUERY_STATISTICS.getStartTime());
Expand All @@ -192,6 +196,7 @@ public void testBuilder() {
assertEquals(END_TIME, LOAD_STATISTICS_INCOMPLETE.getEndTime());
assertEquals(INPUT_BYTES, LOAD_STATISTICS_INCOMPLETE.getInputBytes());
assertEquals(INPUT_FILES, LOAD_STATISTICS_INCOMPLETE.getInputFiles());
assertEquals(BAD_RECORDS, LOAD_STATISTICS_INCOMPLETE.getBadRecords());
assertEquals(null, LOAD_STATISTICS_INCOMPLETE.getOutputBytes());
assertEquals(null, LOAD_STATISTICS_INCOMPLETE.getOutputRows());

Expand Down