Package io.crate.action.sql

Examples of io.crate.action.sql.SQLResponse.rowCount()


    }

    @Test
    public void testClusterSettingsSerialization() throws Exception {
        SQLResponse r = client.sql("select settings from sys.cluster").actionGet();
        assertThat(r.rowCount(), is(1L));
        assertTrue(r.rows()[0][0] instanceof Map);
    }
}
View Full Code Here


    public void testGroupByArbitrary() throws Exception {
        this.setup.groupBySetup();

        execute("select arbitrary(name), race from characters group by race order by race asc");
        SQLResponse arbitrary_response = response;
        assertEquals(3, arbitrary_response.rowCount());

        assertEquals("Android", arbitrary_response.rows()[0][1]);
        assertEquals(1,
                execute("select name from characters where race=? AND name=? ",
                        new Object[]{"Android", arbitrary_response.rows()[0][0]})
View Full Code Here

        assertThat(response.rowCount(), is(1L));
        waitNoPendingTasksOnAll();

        response = executor.exec(
                "select settings['stats']['operations_log_size'], settings['stats']['enabled'] from sys.cluster");
        assertThat(response.rowCount(), is(1L));
        assertThat((Integer)response.rows()[0][0], is(CrateSettings.STATS_OPERATIONS_LOG_SIZE.defaultValue()));
        assertThat((Boolean)response.rows()[0][1], is(CrateSettings.STATS_ENABLED.defaultValue()));
    }

    @Test
View Full Code Here

            fail("expected SQLActionException, none was thrown");
        } catch (SQLActionException e) {
            assertThat(e.getMessage(), is("Invalid value for argument 'stats.operations_log_size'"));

            SQLResponse response = executor.exec("select settings['stats']['operations_log_size'] from sys.cluster");
            assertThat(response.rowCount(), is(1L));
            assertThat((Integer) response.rows()[0][0], is(CrateSettings.STATS_OPERATIONS_LOG_SIZE.defaultValue()));
        }
    }

    @Test
View Full Code Here

        executor.exec("insert into characters (name) values ('sysjobstest')");
        executor.exec("delete from characters where name = 'sysjobstest'");

        SQLResponse response = executor.exec(
                "select * from sys.jobs_log where stmt like 'insert into%' or stmt like 'delete%'");
        assertThat(response.rowCount(), is(2L));
        executor.exec("reset global stats.enabled");
    }

    @Test
    public void testSelectFromJobsLogWithLimit() throws Exception {
View Full Code Here

    @Test
    public void testDistinctSysOperations() throws Exception {
        // this tests a distributing collect without shards but DOC level granularity
        SQLResponse response = executor.exec("select distinct name  from sys.operations");
        // no data since stats.enabled is disabled
        assertThat(response.rowCount(), is(0L));
    }

    @Test
    public void testAddPrimaryKeyColumnToNonEmptyTable() throws Exception {
        expectedException.expect(SQLActionException.class);
View Full Code Here

    }

    @Test
    public void testIsNullOnObjects() throws Exception {
        SQLResponse resp = executor.exec("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"));
View Full Code Here

    @Test
    public void testSysNodesVersionFromMultipleNodes() throws Exception {
        SQLResponse response = executor.exec("select version, version['number'], " +
                "version['build_hash'], version['build_snapshot'] " +
                "from sys.nodes");
        assertThat(response.rowCount(), is(2L));
        for (int i = 0; i <=1 ; i++) {
            assertThat(response.rows()[i][0], instanceOf(Map.class));
            assertThat((Map<String, Object>) response.rows()[i][0], allOf(hasKey("number"), hasKey("build_hash"), hasKey("build_snapshot")));
            assertThat((String) response.rows()[i][1], Matchers.is(Version.CURRENT.number()));
            assertThat((String)response.rows()[i][2], is(Build.CURRENT.hash()));
View Full Code Here

    @Test
    public void testCountWithGroupByOrderOnAggAscFuncAndSecondColumnAndLimit() throws Exception {
        SQLResponse response = executor.exec("select count(*), gender, race from characters " +
            "group by race, gender order by count(*) desc, race, gender asc limit 2");

        assertEquals(2L, response.rowCount());
        assertEquals(2L, response.rows()[0][0]);
        assertEquals("female", response.rows()[0][1]);
        assertEquals("Human", response.rows()[0][2]);
        assertEquals(2L, response.rows()[1][0]);
        assertEquals("male", response.rows()[1][1]);
View Full Code Here

    @Test
    public void testCountWithGroupByOrderOnAggAscFuncAndSecondColumnAndLimitAndOffset() throws Exception {
        SQLResponse response = executor.exec("select count(*), gender, race from characters " +
            "group by race, gender order by count(*) desc, race asc limit 2 offset 2");

        assertEquals(2, response.rowCount());
        assertEquals(2L, response.rows()[0][0]);
        assertEquals("male", response.rows()[0][1]);
        assertEquals("Vogon", response.rows()[0][2]);
        assertEquals(1L, response.rows()[1][0]);
        assertEquals("male", response.rows()[1][1]);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.