Search in sources :

Example 31 with SQLResponse

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));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 32 with SQLResponse

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()));
    }
}
Also used : SQLResponse(io.crate.testing.SQLResponse) TestingHelpers.resolveCanonicalString(io.crate.testing.TestingHelpers.resolveCanonicalString) Test(org.junit.Test)

Example 33 with SQLResponse

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"));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) TestingHelpers.resolveCanonicalString(io.crate.testing.TestingHelpers.resolveCanonicalString) Map(java.util.Map) Test(org.junit.Test)

Example 34 with SQLResponse

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]);
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Example 35 with SQLResponse

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));
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Aggregations

SQLResponse (io.crate.testing.SQLResponse)109 Test (org.junit.Test)78 Map (java.util.Map)13 UseJdbc (io.crate.testing.UseJdbc)10 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)8 PartitionName (io.crate.metadata.PartitionName)4 TestingHelpers.resolveCanonicalString (io.crate.testing.TestingHelpers.resolveCanonicalString)4 Path (java.nio.file.Path)4 BytesRef (org.apache.lucene.util.BytesRef)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 TreeMap (java.util.TreeMap)2 List (java.util.List)1 UUID (java.util.UUID)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ClusterRerouteRequestBuilder (org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder)1 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1