use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class CacheAbstractQueryMetricsSelfTest method testSqlFieldsCrossCacheQueryFailedMetrics.
/**
* Test metrics for failed SQL cross cache queries.
*
* @throws Exception In case of error.
*/
public void testSqlFieldsCrossCacheQueryFailedMetrics() throws Exception {
IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A");
SqlFieldsQuery qry = new SqlFieldsQuery("select * from \"G\".String");
checkQueryFailedMetrics(cache, qry);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class IgniteCacheDistributedJoinCustomAffinityMapper method testJoinCustomAffinityMapper.
/**
* @throws Exception If failed.
*/
public void testJoinCustomAffinityMapper() throws Exception {
Ignite ignite = ignite(0);
IgniteCache<Object, Object> cache = ignite.cache(PERSON_CACHE);
checkQueryFails(cache, "select o._key k1, p._key k2 " + "from \"org\".Organization o, \"personCustomAff\".Person p where o._key=p.orgId", false);
checkQueryFails(cache, "select o._key k1, p._key k2 " + "from \"personCustomAff\".Person p, \"org\".Organization o where o._key=p.orgId", false);
{
// Check regular query does not fail.
SqlFieldsQuery qry = new SqlFieldsQuery("select o._key k1, p._key k2 " + "from \"org\".Organization o, \"personCustomAff\".Person p where o._key=p.orgId");
cache.query(qry).getAll();
}
{
// Should not check affinity for replicated cache.
SqlFieldsQuery qry = new SqlFieldsQuery("select o1._key k1, p._key k2, o2._key k3 " + "from \"org\".Organization o1, \"person\".Person p, \"orgReplCustomAff\".Organization o2 where " + "o1._key=p.orgId and o2._key=p.orgId");
cache.query(qry).getAll();
}
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class IgniteCacheDistributedJoinNoIndexTest method checkNoIndexError.
/**
* @param cache Cache.
* @param sql SQL.
*/
private void checkNoIndexError(final IgniteCache<Object, Object> cache, final String sql) {
Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
SqlFieldsQuery qry = new SqlFieldsQuery(sql);
qry.setDistributedJoins(true);
cache.query(qry).getAll();
return null;
}
}, CacheException.class, null);
log.info("Error: " + err.getMessage());
assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().contains("join condition does not use index"));
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class IgniteCacheDeleteSqlQuerySelfTest method testDeleteSimpleWithoutKeepBinary.
/**
* In binary mode, this test checks that inner forcing of keepBinary works - without it, EntryProcessors
* inside DML engine would compare binary and non-binary objects with the same keys and thus fail.
*/
public void testDeleteSimpleWithoutKeepBinary() {
IgniteCache p = ignite(0).cache("S2P");
QueryCursor<List<?>> c = p.query(new SqlFieldsQuery("delete from Person p where length(p._key) = 2 " + "or p.secondName like '%ite'"));
c.iterator();
c = p.query(new SqlFieldsQuery("select _key, _val, * from Person order by id"));
List<List<?>> leftovers = c.getAll();
assertEquals(2, leftovers.size());
assertEqualsCollections(Arrays.asList("SecondKey", new Person(2, "Joe", "Black"), 2, "Joe", "Black"), leftovers.get(0));
assertEqualsCollections(Arrays.asList("f0u4thk3y", new Person(4, "Jane", "Silver"), 4, "Jane", "Silver"), leftovers.get(1));
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class IgniteCacheDeleteSqlQuerySelfTest method testDeleteSingle.
/**
*
*/
public void testDeleteSingle() {
IgniteCache p = cache();
QueryCursor<List<?>> c = p.query(new SqlFieldsQuery("delete from Person where _key = ?").setArgs("FirstKey"));
c.iterator();
c = p.query(new SqlFieldsQuery("select _key, _val, * from Person order by id, _key"));
List<List<?>> leftovers = c.getAll();
assertEquals(3, leftovers.size());
assertEqualsCollections(Arrays.asList("SecondKey", createPerson(2, "Joe", "Black"), 2, "Joe", "Black"), leftovers.get(0));
assertEqualsCollections(Arrays.asList("k3", createPerson(3, "Sylvia", "Green"), 3, "Sylvia", "Green"), leftovers.get(1));
assertEqualsCollections(Arrays.asList("f0u4thk3y", createPerson(4, "Jane", "Silver"), 4, "Jane", "Silver"), leftovers.get(2));
}
Aggregations