use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class SqlQueryHistorySelfTest method testSqlFieldsQueryHistoryFailed.
/**
* Test metrics for failed SQL queries.
*/
@Test
public void testSqlFieldsQueryHistoryFailed() {
SqlFieldsQuery qry = new SqlFieldsQuery("select * from String where fail()=1");
checkQueryFailedMetrics(qry);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class SqlQueryHistorySelfTest method testSqlFieldsQueryHistoryNotFullyFetched.
/**
* Test metrics for SQL fields queries.
*
* @throws Exception In case of error.
*/
@Test
public void testSqlFieldsQueryHistoryNotFullyFetched() throws Exception {
SqlFieldsQuery qry = new SqlFieldsQuery("select * from String");
qry.setPageSize(10);
checkQueryNotFullyFetchedMetrics(qry, false);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class SqlQueryHistorySelfTest method testQueryHistoryForDmlAndDdl.
/**
* Test metrics eviction.
*
* @throws Exception In case of error.
*/
@Test
public void testQueryHistoryForDmlAndDdl() throws Exception {
IgniteCache<Integer, String> cache = queryNode().context().cache().jcache("A");
List<String> cmds = Arrays.asList("create table TST(id int PRIMARY KEY, name varchar)", "insert into TST(id) values(1)", "commit");
cmds.forEach((cmd) -> cache.query(new SqlFieldsQuery(cmd)).getAll());
checkSeriesCommand(cmds);
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class SqlSchemaSelfTest method testQueryWithoutCacheOnPublicSchema.
/**
* Test query without caches.
*
* @throws Exception If failed.
*/
@Test
public void testQueryWithoutCacheOnPublicSchema() throws Exception {
GridQueryProcessor qryProc = node.context().query();
SqlFieldsQuery qry = new SqlFieldsQuery("SELECT 1").setSchema("PUBLIC");
List<List<?>> res = qryProc.querySqlFields(qry, true).getAll();
assertEquals(1, res.size());
assertEquals(1, res.get(0).size());
assertEquals(1, res.get(0).get(0));
Iterator<List<?>> iter = qryProc.querySqlFields(qry, true).iterator();
assertTrue(iter.hasNext());
List<?> row = iter.next();
assertEquals(1, row.size());
assertEquals(1, row.get(0));
assertFalse(iter.hasNext());
}
use of org.apache.ignite.cache.query.SqlFieldsQuery in project ignite by apache.
the class IgniteSqlSplitterSelfTest method checkQueryWithGroupsAndAggrMixed.
/**
* Query with distinct aggregates and groups
*/
private void checkQueryWithGroupsAndAggrMixed(IgniteCache<Integer, Value> cache) {
try (QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("SELECT fst, count(snd), sum(snd), avg(snd), avg(cast(snd as double)), min(snd), max(snd)," + "count(distinct snd), sum(distinct snd), avg(distinct snd), avg(distinct cast(snd as double)), " + "min(distinct snd), max(distinct snd) FROM Value GROUP BY fst"))) {
List<List<?>> result = qry.getAll();
assertEquals(6, result.size());
List<?> row = result.get(0);
assertEquals("fst", 1, ((Number) row.get(0)).intValue());
assertEquals("count", 3L, ((Number) row.get(1)).longValue());
assertEquals("sum", 9L, ((Number) row.get(2)).longValue());
assertEquals("avg", 3, ((Integer) row.get(3)).intValue());
assertEquals("avg dbl", 3.0d, ((Number) row.get(4)).doubleValue(), 0.001);
assertEquals("min", 3, ((Integer) row.get(5)).intValue());
assertEquals("max", 3, ((Integer) row.get(6)).intValue());
assertEquals("count distinct", 1L, ((Number) row.get(7)).longValue());
assertEquals("sum distinct", 3L, ((Number) row.get(8)).longValue());
assertEquals("avg distinct", 3, ((Integer) row.get(9)).intValue());
assertEquals("avg distinct dbl", 3.0d, ((Number) row.get(10)).doubleValue(), 0.001);
assertEquals("min distinct", 3, ((Integer) row.get(11)).intValue());
assertEquals("max distinct", 3, ((Integer) row.get(12)).intValue());
row = result.get(1);
assertEquals("fst", 2, ((Number) row.get(0)).intValue());
assertEquals("count", 3L, ((Number) row.get(1)).longValue());
assertEquals("sum", 6L, ((Number) row.get(2)).longValue());
assertEquals("avg", 2, ((Integer) row.get(3)).intValue());
assertEquals("avg dbl", 2.0d, ((Number) row.get(4)).doubleValue(), 0.001);
assertEquals("min", 1, ((Integer) row.get(5)).intValue());
assertEquals("max", 3, ((Integer) row.get(6)).intValue());
assertEquals("count distinct", 3L, ((Number) row.get(7)).longValue());
assertEquals("sum distinct", 6L, ((Number) row.get(8)).longValue());
assertEquals("avg distinct", 2, ((Integer) row.get(9)).intValue());
assertEquals("avg distinct dbl", 2.0d, ((Number) row.get(10)).doubleValue(), 0.001);
assertEquals("min distinct", 1, ((Integer) row.get(11)).intValue());
assertEquals("max distinct", 3, ((Integer) row.get(12)).intValue());
row = result.get(2);
assertEquals("fst", 3, ((Number) row.get(0)).intValue());
assertEquals("count", 6L, ((Number) row.get(1)).longValue());
assertEquals("sum", 9L, ((Number) row.get(2)).longValue());
assertEquals("avg", 1, ((Integer) row.get(3)).intValue());
assertEquals("avg dbl", 1.5d, ((Number) row.get(4)).doubleValue(), 0.001);
assertEquals("min", 1, ((Integer) row.get(5)).intValue());
assertEquals("max", 2, ((Integer) row.get(6)).intValue());
assertEquals("count distinct", 2L, ((Number) row.get(7)).longValue());
assertEquals("sum distinct", 3L, ((Number) row.get(8)).longValue());
assertEquals("avg distinct", 1, ((Integer) row.get(9)).intValue());
assertEquals("avg distinct dbl", 1.5d, ((Number) row.get(10)).doubleValue(), 0.001);
assertEquals("min distinct", 1, ((Integer) row.get(11)).intValue());
assertEquals("max distinct", 2, ((Integer) row.get(12)).intValue());
}
}
Aggregations