Skip to content
Closed
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 @@ -3975,6 +3975,11 @@ private <U extends OkHttpResultIterator> U postIteratedResourceImpl(
requestBldr = addTransactionScopedCookies(requestBldr, transaction);
requestBldr = addTelemetryAgentId(requestBldr);

if ("rows".equals(path)) {
requestBldr.addHeader("ML-Check-ML11-Headers", "true");
requestBldr.addHeader("TE", "trailers");
}

Consumer<Boolean> resendableConsumer = new Consumer<Boolean>() {
public void accept(Boolean resendable) {
if (!isResendable) {
Expand Down Expand Up @@ -4501,6 +4506,19 @@ private <U extends OkHttpResultIterator> U makeResults(
getEntity(body, MimeMultipart.class) : null;

List<BodyPart> partList = getPartList(entity);
try {
Headers trailer = response.trailers();

String code = trailer.get("ml-error-code");
String msg = trailer.get("ml-error-message");
String sha = trailer.get("ml-content-sha256");

if (!"N/A".equals(code)) {
throw new RuntimeException("code = " + code + ", msg = " + msg + ", sha256 = " + sha);
}
} catch (IOException e) {
e.printStackTrace();
}
Closeable closeable = response;
return makeResults(constructor, reqlog, operation, entityType, partList, response, closeable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,24 @@ public void testView() {

testViewRows(rowMgr.resultRows(builtPlan));
}

@Test
public void testSQLException() {
RowManager rowMgr = Common.client.newRowManager();

PlanBuilder p = rowMgr.newPlanBuilder();

PlanBuilder.ExportablePlan builtPlan =
p.fromSql("select case when lastName = 'Davis' then fn_error(fn_qname('ERROR','test')) end, opticUnitTest.musician.* from (select * from opticUnitTest.musician order by lastName)");
String exception = "";
try {
rowMgr.resultRows(builtPlan);
} catch (Exception e) {
int index = e.getMessage().indexOf("sha256");
exception = e.getMessage().substring(0, index-2);
}
assertEquals(exception, "code = test, msg = error");
}
private void testViewRows(RowSet<RowRecord> rows) {
String[] lastName = {"Armstrong", "Davis"};
String[] firstName = {"Louis", "Miles"};
Expand Down