use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testCountWithGroupByOrderOnAggDescFuncAndLimit.
@Test
public void testCountWithGroupByOrderOnAggDescFuncAndLimit() throws Exception {
SQLResponse response = execute("select count(*), race from characters group by race order by count(*) desc limit 2");
assertEquals(2, response.rowCount());
assertEquals(4L, response.rows()[0][0]);
assertEquals("Human", response.rows()[0][1]);
assertEquals(2L, response.rows()[1][0]);
assertEquals("Vogon", response.rows()[1][1]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testGroupByNestedObject.
@Test
public void testGroupByNestedObject() throws Exception {
SQLResponse response = execute("select count(*), details['job'] from characters " + "group by details['job'] order by count(*), details['job']");
assertEquals(3, response.rowCount());
assertEquals(1L, response.rows()[0][0]);
assertEquals("Mathematician", response.rows()[0][1]);
assertEquals(1L, response.rows()[1][0]);
assertEquals("Sandwitch Maker", response.rows()[1][1]);
assertEquals(5L, response.rows()[2][0]);
assertNull(null, response.rows()[2][1]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testIsNullOnObjects.
@Test
public void testIsNullOnObjects() throws Exception {
SQLResponse resp = execute("select name from characters where details is null order by name");
assertThat(resp.rowCount(), is(5L));
List<String> names = new ArrayList<>(5);
for (Object[] objects : resp.rows()) {
names.add((String) objects[0]);
}
assertThat(names, Matchers.contains("Anjie", "Ford Perfect", "Jeltz", "Kwaltz", "Marving"));
resp = execute("select count(*) from characters where details is not null");
assertThat((Long) resp.rows()[0][0], is(2L));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testOrderByNullsFirstAndLast.
@Test
public void testOrderByNullsFirstAndLast() throws Exception {
SQLResponse response = execute("select details['job'] from characters order by details['job'] nulls first limit 1");
assertNull(response.rows()[0][0]);
response = execute("select details['job'] from characters order by details['job'] desc nulls first limit 1");
assertNull(response.rows()[0][0]);
response = execute("select details['job'] from characters order by details['job'] nulls last");
assertNull(response.rows()[((Long) response.rowCount()).intValue() - 1][0]);
response = execute("select details['job'] from characters order by details['job'] desc nulls last");
assertNull(response.rows()[((Long) response.rowCount()).intValue() - 1][0]);
response = execute("select distinct details['job'] from characters order by details['job'] desc nulls last");
assertNull(response.rows()[((Long) response.rowCount()).intValue() - 1][0]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testCountWithGroupByOrderOnAggAscFuncAndLimit.
@Test
public void testCountWithGroupByOrderOnAggAscFuncAndLimit() throws Exception {
SQLResponse response = execute("select count(*), race from characters " + "group by race order by count(*) asc limit ?", new Object[] { 2 });
assertEquals(2, response.rowCount());
assertEquals(1L, response.rows()[0][0]);
assertEquals("Android", response.rows()[0][1]);
assertEquals(2L, response.rows()[1][0]);
assertEquals("Vogon", response.rows()[1][1]);
}
Aggregations