Details
Description
Case when SQL query `SELECT COUNT FROM T` with partitions invoked for REPLICATED cache data don't work properly.
/** */ public class QueryWithPartitionsIntegration2Test extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.getSqlConfiguration().setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration()); return cfg; } /** */ @Test public void testSelectCount() throws Exception { startGrid(0).createCache(DEFAULT_CACHE_NAME); sql("CREATE TABLE T(ID INT PRIMARY KEY, IDX_VAL VARCHAR, VAL VARCHAR) WITH template=replicated"); StringBuilder sb = new StringBuilder("INSERT INTO T(ID, IDX_VAL, VAL) VALUES "); int cnt = 10_000; for (int i = 0; i < cnt; ++i) { if (i != 0) sb.append(","); sb.append("(").append(i).append(", ") .append("'name_").append(i).append("', ") .append("'name_").append(i).append("')"); } sql(sb.toString()); assertEquals((long)cnt, sql("SELECT COUNT(*) FROM T").get(0).get(0)); assertNotEquals((long)cnt, sql("SELECT COUNT(*) FROM T", 42).get(0).get(0)); } /** */ public List<List<?>> sql(String sqlText, int... parts) { SqlFieldsQuery qry = new SqlFieldsQuery(sqlText).setTimeout(5, TimeUnit.SECONDS); if (!F.isEmpty(parts)) qry.setPartitions(parts); return grid(0).cache(F.first(grid(0).cacheNames())).query(qry).getAll(); } }
Attachments
Issue Links
- is caused by
-
IGNITE-19998 Calcite-2. Add support of partitions in SqlFieldsQuery
- Resolved