use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class TestMemorySelection method testIndexSingleColMultiOperatorsVerifyResults.
@Test(dataProvider = "memConIndexSingleColMultiOperators")
public void testIndexSingleColMultiOperatorsVerifyResults(String queryOperator) throws InterruptedException {
assertQuerySucceeds("CREATE TABLE test_indexOperations WITH (sorted_by=ARRAY['custkey'], async_processing=false) AS SELECT * FROM tpch.tiny.orders");
// get how many test keys there are
long testKeys = queryOperator.chars().filter(c -> c == '#').count();
// get custkeys
List<Object> results = getResults("SELECT * from (SELECT custkey FROM test_indexOperations LIMIT " + testKeys + ") ORDER BY custkey ASC");
String tmpQueryOperator = queryOperator;
for (Object key : results) {
tmpQueryOperator = tmpQueryOperator.replaceFirst("#", String.valueOf((long) key));
}
String predicateQuery = "SELECT count(distinct custkey) FROM test_indexOperations WHERE " + tmpQueryOperator;
MaterializedResult result1 = computeActual(predicateQuery.replace("test_indexOperations", "tpch.tiny.orders"));
MaterializedResult result2 = computeActual(predicateQuery);
// Drop table for next use
assertQuerySucceeds("DROP TABLE test_indexOperations");
System.out.println(predicateQuery);
ArrayList<String> data1 = new ArrayList<>();
ArrayList<String> data2 = new ArrayList<>();
for (MaterializedRow item1 : result1.getMaterializedRows()) {
data1.add(item1.toString());
}
for (MaterializedRow item2 : result2.getMaterializedRows()) {
data2.add(item2.toString());
}
Collections.sort(data1);
Collections.sort(data2);
System.out.println(data1.size());
System.out.println();
System.out.println(data2.size());
assertEquals(data1, data2);
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class TestMemorySelection method getSingleResult.
private Object getSingleResult(@Language("SQL") String sql) {
MaterializedResult rows = computeActual(sql);
assertTrue(rows.getRowCount() > 0);
MaterializedRow materializedRow = rows.getMaterializedRows().get(0);
int fieldCount = materializedRow.getFieldCount();
assertTrue(fieldCount == 1, format("Expected only one column, but got '%d'", fieldCount));
Object value = materializedRow.getField(0);
return value;
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class TestMemorySelection method getResults.
private List<Object> getResults(@Language("SQL") String sql) {
MaterializedResult rows = computeActual(sql);
List<Object> values = new ArrayList<>();
for (MaterializedRow materializedRow : rows.getMaterializedRows()) {
int fieldCount = materializedRow.getFieldCount();
assertTrue(fieldCount == 1, format("Expected only one column, but got '%d'", fieldCount));
values.add(materializedRow.getField(0));
}
return values;
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class TestMemorySmoke method assertQueryResult.
private void assertQueryResult(@Language("SQL") String sql, Object... expected) {
MaterializedResult rows = computeActual(sql);
assertEquals(rows.getRowCount(), expected.length);
for (int i = 0; i < expected.length; i++) {
MaterializedRow materializedRow = rows.getMaterializedRows().get(i);
int fieldCount = materializedRow.getFieldCount();
assertTrue(fieldCount == 1, format("Expected only one column, but got '%d'", fieldCount));
Object value = materializedRow.getField(0);
assertEquals(value, expected[i]);
assertTrue(materializedRow.getFieldCount() == 1);
}
}
use of io.prestosql.testing.MaterializedRow in project hetu-core by openlookeng.
the class TestMemorySelection method assertQueryResult.
private void assertQueryResult(@Language("SQL") String sql, Object... expected) {
MaterializedResult rows = computeActual(sql);
assertEquals(rows.getRowCount(), expected.length);
for (int i = 0; i < expected.length; i++) {
MaterializedRow materializedRow = rows.getMaterializedRows().get(i);
int fieldCount = materializedRow.getFieldCount();
assertTrue(fieldCount == 1, format("Expected only one column, but got '%d'", fieldCount));
Object value = materializedRow.getField(0);
assertEquals(value, expected[i]);
assertTrue(materializedRow.getFieldCount() == 1);
}
}
Aggregations