use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class JdbcUpdateStatementSelfTest method testExecute.
/**
*
*/
public void testExecute() throws SQLException {
conn.createStatement().execute("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0");
assertEquals(Arrays.asList(F.asList("John"), F.asList("Jack"), F.asList("Mike")), jcache(0).query(new SqlFieldsQuery("select firstName from Person order by _key")).getAll());
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class JdbcUpdateStatementSelfTest method testExecuteUpdate.
/**
*
*/
public void testExecuteUpdate() throws SQLException {
conn.createStatement().executeUpdate("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0");
assertEquals(Arrays.asList(F.asList("John"), F.asList("Jack"), F.asList("Mike")), jcache(0).query(new SqlFieldsQuery("select firstName from Person order by _key")).getAll());
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class JdbcThinDynamicIndexAbstractSelfTest method testCreateIndex.
/**
* Test that after index creation index is used by queries.
* @throws SQLException If failed.
*/
public void testCreateIndex() throws SQLException {
assertSize(3);
assertColumnValues(30, 20, 10);
jdbcRun(CREATE_INDEX);
// Test that local queries on all server nodes use new index.
for (int i = 0; i < 3; i++) {
List<List<?>> locRes = ignite(i).cache(DEFAULT_CACHE_NAME).query(new SqlFieldsQuery("explain select id from " + "Person where id = 5").setLocal(true)).getAll();
assertEquals(F.asList(Collections.singletonList("SELECT\n" + " ID\n" + "FROM \"" + DEFAULT_CACHE_NAME + "\".PERSON\n" + " /* \"" + DEFAULT_CACHE_NAME + "\".IDX: ID = 5 */\n" + "WHERE ID = 5")), locRes);
}
assertSize(3);
assertColumnValues(30, 20, 10);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class JdbcThinDynamicIndexAbstractSelfTest method testDropIndex.
/**
* Test that after index drop there are no attempts to use it, and data state remains intact.
* @throws SQLException If failed.
*/
public void testDropIndex() throws SQLException {
assertSize(3);
jdbcRun(CREATE_INDEX);
assertSize(3);
jdbcRun(DROP_INDEX);
// Test that no local queries on server nodes use new index.
for (int i = 0; i < 3; i++) {
List<List<?>> locRes = ignite(i).cache(DEFAULT_CACHE_NAME).query(new SqlFieldsQuery("explain select id from " + "Person where id = 5").setLocal(true)).getAll();
assertEquals(F.asList(Collections.singletonList("SELECT\n" + " ID\n" + "FROM \"" + DEFAULT_CACHE_NAME + "\".PERSON\n" + " /* \"" + DEFAULT_CACHE_NAME + "\".PERSON.__SCAN_ */\n" + "WHERE ID = 5")), locRes);
}
assertSize(3);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class JdbcThinUpdateStatementSelfTest method testExecute.
/**
* @throws SQLException If failed.
*/
public void testExecute() throws SQLException {
conn.createStatement().execute("update Person set firstName = 'Jack' where " + "cast(substring(_key, 2, 1) as int) % 2 = 0");
assertEquals(Arrays.asList(F.asList("John"), F.asList("Jack"), F.asList("Mike")), jcache(0).query(new SqlFieldsQuery("select firstName from Person order by _key")).getAll());
}
Aggregations