use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person in project ignite by apache.
the class H2DynamicTableSelfTest method doTestCreateTable.
/**
* Test that {@code CREATE TABLE} with given template cache name actually creates new cache,
* H2 table and type descriptor on all nodes, optionally with cache type check.
* @param tplCacheName Template cache name.
* @param mode Expected cache mode, or {@code null} if no check is needed.
*/
private void doTestCreateTable(String tplCacheName, CacheMode mode) {
executeDdl("CREATE TABLE \"Person\" (\"id\" int, \"city\" varchar," + " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " + (F.isEmpty(tplCacheName) ? "" : "\"template=" + tplCacheName + "\",") + "\"backups=10,atomicity=atomic\"");
for (int i = 0; i < 4; i++) {
IgniteEx node = grid(i);
assertNotNull(node.cache("Person"));
DynamicCacheDescriptor cacheDesc = node.context().cache().cacheDescriptor("Person");
assertNotNull(cacheDesc);
if (mode == CacheMode.REPLICATED)
assertEquals(Integer.MAX_VALUE, cacheDesc.cacheConfiguration().getBackups());
else
assertEquals(10, cacheDesc.cacheConfiguration().getBackups());
assertEquals(CacheAtomicityMode.ATOMIC, cacheDesc.cacheConfiguration().getAtomicityMode());
assertTrue(cacheDesc.sql());
if (mode != null)
assertEquals(mode, cacheDesc.cacheConfiguration().getCacheMode());
QueryTypeDescriptorImpl desc = typeExisting(node, "Person", "Person");
assertEquals(Object.class, desc.keyClass());
assertEquals("PersonKey", desc.keyTypeName());
assertEquals(Object.class, desc.valueClass());
assertEquals("Person", desc.valueTypeName());
assertEquals(F.asList("id", "city", "name", "surname", "age"), new ArrayList<>(desc.fields().keySet()));
assertProperty(desc, "id", Integer.class, true);
assertProperty(desc, "city", String.class, true);
assertProperty(desc, "name", String.class, false);
assertProperty(desc, "surname", String.class, false);
assertProperty(desc, "age", Integer.class, false);
GridH2Table tbl = ((IgniteH2Indexing) node.context().query().getIndexing()).dataTable("PUBLIC", "Person");
assertNotNull(tbl);
}
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person in project ignite by apache.
the class UpdatePlan method createRows.
/**
* Extract rows from plan without performing any query.
*
* @param argss Batch of arguments.
* @return {@link List} of rows from the plan for each query.
* For example, if we have a batch of queries with multiple args: <br/>
* <code>
* INSERT INTO person VALUES (k1, v1), (k2, v2), (k3, v3); <br/>
* INSERT INTO person VALUES (k4, v4), (k5, v5), (k6, v6);<br/>
* </code>
* we will get a {@link List} of {@link List} of {@link List} with items: <br/>
* <code>
* {[k1, v1], [k2, v2], [k3, v3]},<br/>
* {[k4, v4], [k5, v5], [k6, v6]}<br/>
*
* @throws IgniteCheckedException If failed.
*/
public List<List<List<?>>> createRows(List<Object[]> argss) throws IgniteCheckedException {
assert rowsNum > 0 && !F.isEmpty(colNames);
assert argss != null;
List<List<List<?>>> resPerQry = new ArrayList<>(argss.size());
GridH2RowDescriptor desc = tbl.rowDescriptor();
for (Object[] args : argss) {
List<List<?>> res = new ArrayList<>();
resPerQry.add(res);
extractArgsValues(args, res, desc);
}
return resPerQry;
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person in project ignite by apache.
the class RetryCauseMessageSelfTest method testGrpReservationFailureMessage.
/**
* Failed to reserve partitions for query (group reservation failed)
*/
@Test
public void testGrpReservationFailureMessage() {
final GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec");
final ConcurrentMap<PartitionReservationKey, GridReservable> reservations = reservations(h2Idx);
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", new MockGridMapQueryExecutor() {
@Override
public void onQueryRequest(ClusterNode node, GridH2QueryRequest qryReq) throws IgniteCheckedException {
final PartitionReservationKey grpKey = new PartitionReservationKey(ORG, null);
reservations.put(grpKey, new GridReservable() {
@Override
public boolean reserve() {
return false;
}
@Override
public void release() {
}
});
startedExecutor.onQueryRequest(node, qryReq);
}
}.insertRealExecutor(mapQryExec));
SqlQuery<String, Person> qry = new SqlQuery<String, Person>(Person.class, JOIN_SQL).setArgs("Organization #0");
qry.setDistributedJoins(true);
try {
personCache.query(qry).getAll();
} catch (CacheException e) {
assertTrue(e.getMessage().contains("Failed to reserve partitions for query (group reservation failed) ["));
return;
} finally {
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", mapQryExec);
}
fail();
}
Aggregations