Skip to content

Commit

Permalink
chore: add bq log error messages (#80)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jesrypandawa authored Feb 28, 2023
1 parent a018d59 commit cbf03e4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
}

group 'io.odpf'
version '0.3.7'
version '0.3.8'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public static Map<Long, ErrorInfo> getErrorsFromBQResponse(
Record record = records.get(errorEntry.getKey().intValue());
long messageIndex = record.getIndex();
List<ErrorDescriptor> errors = ErrorParser.parseError(errorEntry.getValue());
instrumentation.logError("Error while bigquery insert for message. Record: {}, Error: {}, MetaData: {}, BQ errors {}",
record.getColumns(), errors, record.getMetadata(), errorEntry.getValue());
instrumentation.logError("Error while bigquery insert for message. Record: {}, Error: {}, MetaData: {}",
record.getColumns(), errors, record.getMetadata());

if (errorMatch(errors, UnknownError.class)) {
errorInfoResponse.put(messageIndex, new ErrorInfo(new BigQuerySinkException(), ErrorType.SINK_UNKNOWN_ERROR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static ErrorDescriptor getError(String reasonText, String msgText) {
.stream()
.filter(ErrorDescriptor::matches)
.findFirst()
.orElse(new UnknownError());
.orElse(new UnknownError(reasonText, msgText));
}

public static List<ErrorDescriptor> parseError(List<BigQueryError> bqErrors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public boolean matches() {

@Override
public String toString() {
return "InvalidSchemaError";
return String.format("InvalidSchemaError: %s", message);
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/odpf/depot/bigquery/error/OOBError.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public boolean matches() {
&& ((message.contains("is outside the allowed bounds") && message.contains("days in the past and") && message.contains("days in the future"))
|| message.contains("out of range"));
}

@Override
public String toString() {
return "OOBError";
return String.format("OOBError: %s", message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public boolean matches() {

@Override
public String toString() {
return "Stopped";
return "StoppedError: Failed to insert this row because of some (other)error records in batch";
}
}
6 changes: 5 additions & 1 deletion src/main/java/io/odpf/depot/bigquery/error/UnknownError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* */
public class UnknownError implements ErrorDescriptor {

private String reason;

private String message;

@Override
public boolean matches() {
return false;
}

@Override
public String toString() {
return "UnknownError";
return String.format("%s: %s", !reason.equals("") ? reason : "UnknownError", message != null ? message : "");
}
}

0 comments on commit cbf03e4

Please sign in to comment.