use of io.crate.testing.SQLResponse in project crate by crate.
the class SysShardsTest method testSelectGreaterThan.
@Test
public void testSelectGreaterThan() throws Exception {
SQLResponse response = execute("select * from sys.shards where num_docs > 0");
assertThat(response.rowCount(), greaterThan(0L));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class SysShardsTest method testSelectOrderBy.
@Test
public void testSelectOrderBy() throws Exception {
SQLResponse response = execute("select table_name, min_lucene_version, * " + "from sys.shards order by table_name");
assertEquals(26L, response.rowCount());
List<String> tableNames = Arrays.asList("blobs", "characters", "quotes");
for (Object[] row : response.rows()) {
assertThat(tableNames.contains(row[0]), is(true));
assertThat(row[1], is(Version.LATEST.toString()));
}
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class SysShardsTest method testSelectNodeSysExpression.
@Test
public void testSelectNodeSysExpression() throws Exception {
SQLResponse response = execute("select _node, _node['name'], id from sys.shards order by _node['name'], id limit 1");
assertEquals(1L, response.rowCount());
Map<String, Object> fullNode = (Map<String, Object>) response.rows()[0][0];
String nodeName = response.rows()[0][1].toString();
assertEquals("node_s0", nodeName);
assertEquals("node_s0", fullNode.get("name"));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testGlobalAggregateSimple.
@Test
public void testGlobalAggregateSimple() throws Exception {
SQLResponse response = execute("select max(age) from characters");
assertEquals(1, response.rowCount());
assertEquals("max(age)", response.cols()[0]);
assertEquals(112, response.rows()[0][0]);
response = execute("select min(name) from characters");
assertEquals(1, response.rowCount());
assertEquals("min(name)", response.cols()[0]);
assertEquals("Anjie", response.rows()[0][0]);
response = execute("select avg(age) as median_age from characters");
assertEquals(1, response.rowCount());
assertEquals("median_age", response.cols()[0]);
assertEquals(55.25d, response.rows()[0][0]);
response = execute("select sum(age) as sum_age from characters");
assertEquals(1, response.rowCount());
assertEquals("sum_age", response.cols()[0]);
assertEquals(221.0d, response.rows()[0][0]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testDateRange.
@Test
public void testDateRange() throws Exception {
SQLResponse response = execute("select * from characters where birthdate > '1970-01-01'");
assertThat(response.rowCount(), Matchers.is(2L));
}
Aggregations