Skip to content

Commit cbf03e4

Browse files
authored
chore: add bq log error messages (#80)
* add error messages on bq sink exception * bump up version to 0.3.8 * chore: update error message in toString Error class * handle empty string for reason on UnknownError
1 parent a018d59 commit cbf03e4

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ plugins {
2222
}
2323

2424
group 'io.odpf'
25-
version '0.3.7'
25+
version '0.3.8'
2626

2727
repositories {
2828
mavenCentral()

src/main/java/io/odpf/depot/bigquery/client/BigQueryResponseParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static Map<Long, ErrorInfo> getErrorsFromBQResponse(
4242
Record record = records.get(errorEntry.getKey().intValue());
4343
long messageIndex = record.getIndex();
4444
List<ErrorDescriptor> errors = ErrorParser.parseError(errorEntry.getValue());
45-
instrumentation.logError("Error while bigquery insert for message. Record: {}, Error: {}, MetaData: {}, BQ errors {}",
46-
record.getColumns(), errors, record.getMetadata(), errorEntry.getValue());
45+
instrumentation.logError("Error while bigquery insert for message. Record: {}, Error: {}, MetaData: {}",
46+
record.getColumns(), errors, record.getMetadata());
4747

4848
if (errorMatch(errors, UnknownError.class)) {
4949
errorInfoResponse.put(messageIndex, new ErrorInfo(new BigQuerySinkException(), ErrorType.SINK_UNKNOWN_ERROR));

src/main/java/io/odpf/depot/bigquery/error/ErrorParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static ErrorDescriptor getError(String reasonText, String msgText) {
2323
.stream()
2424
.filter(ErrorDescriptor::matches)
2525
.findFirst()
26-
.orElse(new UnknownError());
26+
.orElse(new UnknownError(reasonText, msgText));
2727
}
2828

2929
public static List<ErrorDescriptor> parseError(List<BigQueryError> bqErrors) {

src/main/java/io/odpf/depot/bigquery/error/InvalidSchemaError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public boolean matches() {
2222

2323
@Override
2424
public String toString() {
25-
return "InvalidSchemaError";
25+
return String.format("InvalidSchemaError: %s", message);
2626
}
2727
}

src/main/java/io/odpf/depot/bigquery/error/OOBError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public boolean matches() {
1818
&& ((message.contains("is outside the allowed bounds") && message.contains("days in the past and") && message.contains("days in the future"))
1919
|| message.contains("out of range"));
2020
}
21+
2122
@Override
2223
public String toString() {
23-
return "OOBError";
24+
return String.format("OOBError: %s", message);
2425
}
25-
2626
}

src/main/java/io/odpf/depot/bigquery/error/StoppedError.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public boolean matches() {
2222

2323
@Override
2424
public String toString() {
25-
return "Stopped";
25+
return "StoppedError: Failed to insert this row because of some (other)error records in batch";
2626
}
2727
}

src/main/java/io/odpf/depot/bigquery/error/UnknownError.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@
99
* */
1010
public class UnknownError implements ErrorDescriptor {
1111

12+
private String reason;
13+
14+
private String message;
15+
1216
@Override
1317
public boolean matches() {
1418
return false;
1519
}
1620

1721
@Override
1822
public String toString() {
19-
return "UnknownError";
23+
return String.format("%s: %s", !reason.equals("") ? reason : "UnknownError", message != null ? message : "");
2024
}
2125
}

0 commit comments

Comments
 (0)