use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class QueryParser method queryDescriptor.
/**
* Prepare plan key.
*
* @param schemaName Schema name.
* @param qry Query.
* @return Plan key.
*/
private static QueryDescriptor queryDescriptor(String schemaName, SqlFieldsQuery qry) {
boolean skipReducerOnUpdate = false;
boolean batched = false;
if (qry instanceof SqlFieldsQueryEx) {
SqlFieldsQueryEx qry0 = (SqlFieldsQueryEx) qry;
skipReducerOnUpdate = !qry.isLocal() && qry0.isSkipReducerOnUpdate();
batched = qry0.isBatched();
}
return new QueryDescriptor(schemaName, qry.getSql(), qry.isCollocated(), qry.isDistributedJoins(), qry.isEnforceJoinOrder(), qry.isLocal(), skipReducerOnUpdate, batched, qry.getQueryInitiatorId());
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class QueryParser method queryParameters.
/**
* Create parameters from query.
*
* @param qry Query.
* @return Parameters.
*/
public QueryParameters queryParameters(SqlFieldsQuery qry) {
NestedTxMode nestedTxMode = NestedTxMode.DEFAULT;
boolean autoCommit = true;
List<Object[]> batchedArgs = null;
if (qry instanceof SqlFieldsQueryEx) {
SqlFieldsQueryEx qry0 = (SqlFieldsQueryEx) qry;
if (qry0.getNestedTxMode() != null)
nestedTxMode = qry0.getNestedTxMode();
autoCommit = qry0.isAutoCommit();
batchedArgs = qry0.batchedArguments();
}
int timeout = qry.getTimeout();
if (timeout < 0)
timeout = (int) idx.distributedConfiguration().defaultQueryTimeout();
return new QueryParameters(qry.getArgs(), qry.getPartitions(), timeout, qry.isLazy(), qry.getPageSize(), null, nestedTxMode, autoCommit, batchedArgs, qry.getUpdateBatchSize());
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method testQueryParallelism.
/**
* @throws Exception if failed.
*/
@SuppressWarnings("ConstantConditions")
@Test
public void testQueryParallelism() throws Exception {
String cacheName = CACHE_ORG + "x4";
CacheConfiguration cfg = buildCacheConfiguration(CACHE_ORG).setQueryParallelism(4).setName(cacheName);
IgniteCache<Integer, Organization> cache = grid(NODE_CLIENT).createCache(cfg);
for (int i = 0; i < 1024; i++) cache.put(i, new Organization("Acme Inc #" + i, 0));
List<List<?>> r = cache.query(new SqlFieldsQueryEx("UPDATE \"" + cacheName + "\".Organization o SET name = UPPER(name)", false).setSkipReducerOnUpdate(true)).getAll();
assertEquals((long) cache.size(), r.get(0).get(0));
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest method testDeleteWhereSubquery.
/**
*/
@Test
public void testDeleteWhereSubquery() {
Map<Integer, Account> accounts = getAccounts(20, 1, 100);
Map<Integer, Trade> trades = getTrades(10, 2);
client.cache(CACHE_ACCOUNT).putAll(accounts);
client.cache(CACHE_TRADE).putAll(trades);
String text = "DELETE FROM \"acc\".Account " + "WHERE _key IN (SELECT t.accountId FROM \"trade\".Trade t)";
checkUpdate(client.cache(CACHE_ACCOUNT), accounts, new SqlFieldsQueryEx(text, false));
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest method testUpdateSetTableSubquery.
/**
*/
@Test
public void testUpdateSetTableSubquery() {
Map<Integer, Account> accounts = getAccounts(100, 1, 1000);
Map<Integer, Trade> trades = getTrades(100, 2);
client.cache(CACHE_ACCOUNT).putAll(accounts);
String text = "UPDATE \"trade\".Trade t SET (qty) = " + "(SELECT a.depo/t.price FROM \"acc\".Account a WHERE t.accountId = a._key)";
checkUpdate(client.cache(CACHE_TRADE), trades, new SqlFieldsQueryEx(text, false));
}
Aggregations