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 @@ -43,10 +43,7 @@

import java.io.BufferedReader;
import java.io.StringReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -203,6 +200,24 @@ public void testJsonRowsForest2Threads() throws Exception {
public void testJsonDocs1Thread() throws Exception {
runDocsTest(jsonBatcher(1));
}

@Test
void noRowsReturned() {
RowBatcher<JsonNode> rowBatcher = jsonBatcher(1);
RowManager rowMgr = rowBatcher.getRowManager();
RawQueryDSLPlan plan = rowMgr.newRawQueryDSLPlan(
new StringHandle("op.fromView('rowBatcherUnitTest', 'code').where(op.eq(op.col('field1'), 12345))"));

List<JsonNode> results = new ArrayList<>();
rowBatcher.withBatchView(plan).onSuccess(batch -> results.add(batch.getRowsDoc()));
moveMgr.startJob(rowBatcher);
rowBatcher.awaitCompletion();
moveMgr.stopJob(rowBatcher);

assertEquals(0, results.size(), "Expecting no results as the Optic query shouldn't match any rows; " +
"also expecting no error to occur.");
}

@Test
public void testJsonDocs3Threads() throws Exception {
runDocsTest(jsonBatcher(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,30 @@ private void testViewRows(RowSet<RowRecord> rows) {
assertEquals( 2, rowNum);
}

@Test
public void testSQL() {
RowManager rowMgr = Common.client.newRowManager();
PlanBuilder p = rowMgr.newPlanBuilder();
PlanBuilder.ExportablePlan builtPlan =
p.fromSql("select * from opticUnitTest.musician_ml10");
int rowNum = 0;
String exception = "";
try {
for (RowRecord row: rowMgr.resultRows(builtPlan)) {
rowNum++;
}
} catch (Exception e) {
exception = e.toString();
}
assertEquals(4, rowNum);
assertEquals("", exception);
}
@Test
void testSQL() {
final String query = "select * from opticUnitTest.musician_ml10";
RowManager mgr = Common.client.newRowManager();

RowSet<RowRecord> rows = mgr.resultRows(mgr.newPlanBuilder().fromSql(query));
assertEquals(4, rows.stream().count());

JsonNode doc = mgr.resultDoc(mgr.newPlanBuilder().fromSql(query), new JacksonHandle()).get();
assertEquals(3, doc.get("columns").size());
assertEquals(4, doc.get("rows").size());
}

@Test
void sqlNoRows() {
final String query = "select * from opticUnitTest.musician_ml10 where lastName = 'NOT_FOUND'";
RowManager mgr = Common.client.newRowManager();

RowSet<RowRecord> rows = mgr.resultRows(mgr.newPlanBuilder().fromSql(query));
assertEquals(0, rows.stream().count());

JsonNode doc = mgr.resultDoc(mgr.newPlanBuilder().fromSql(query), new JacksonHandle()).get();
assertNull(doc);
}

@Test
public void testSQL0Result() {
Expand Down