use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class WarningOnBigQueryResultsTest method testDisableWarning.
/**
*/
@Test
public void testDisableWarning() throws Exception {
setBigResultThreshold(grid(0), 0, 0);
setBigResultThreshold(grid(1), 0, 0);
setBigResultThreshold(grid(2), 0, 0);
setBigResultThreshold(grid(3), 0, 0);
assertEquals(KEYS_PER_NODE * 2, grid("cli").context().query().querySqlFields(new SqlFieldsQueryEx("SELECT * FROM TEST0", true).setSchema("TEST0"), false).getAll().size());
assertEquals(0, listener(grid(0)).messageCount());
assertEquals(0, listener(grid(1)).messageCount());
assertEquals(0, listener(grid(2)).messageCount());
assertEquals(0, listener(grid(3)).messageCount());
assertEquals(KEYS_PER_NODE * 2, grid("cli").context().query().querySqlFields(new SqlFieldsQueryEx("SELECT * FROM TEST1", true).setSchema("TEST1"), false).getAll().size());
assertEquals(0, listener(grid(0)).messageCount());
assertEquals(0, listener(grid(1)).messageCount());
assertEquals(0, listener(grid(2)).messageCount());
assertEquals(0, listener(grid(3)).messageCount());
setBigResultThreshold(grid(0), -1, -1);
setBigResultThreshold(grid(1), -1, -1);
setBigResultThreshold(grid(2), -1, -1);
setBigResultThreshold(grid(3), -1, -1);
assertEquals(KEYS_PER_NODE * 2, grid("cli").context().query().querySqlFields(new SqlFieldsQueryEx("SELECT * FROM TEST0", true).setSchema("TEST0"), false).getAll().size());
assertEquals(0, listener(grid(0)).messageCount());
assertEquals(0, listener(grid(1)).messageCount());
assertEquals(0, listener(grid(2)).messageCount());
assertEquals(0, listener(grid(3)).messageCount());
assertEquals(KEYS_PER_NODE * 2, grid("cli").context().query().querySqlFields(new SqlFieldsQueryEx("SELECT * FROM TEST1", true).setSchema("TEST1"), false).getAll().size());
assertEquals(0, listener(grid(0)).messageCount());
assertEquals(0, listener(grid(1)).messageCount());
assertEquals(0, listener(grid(2)).messageCount());
assertEquals(0, listener(grid(3)).messageCount());
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class JdbcPreparedStatement method parameterMetaData.
/**
* Fetches parameters metadata of the specified query.
*/
private ParameterMetaData parameterMetaData() throws SQLException {
SqlFieldsQueryEx qry = new SqlFieldsQueryEx(sql, null);
setupQuery(qry);
try {
List<JdbcParameterMeta> params = conn.ignite().context().query().getIndexing().parameterMetaData(conn.schemaName(), qry);
return new JdbcThinParameterMetadata(params);
} catch (IgniteSQLException ex) {
throw ex.toJdbcException();
}
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest method testInsertFromSelectDistinct.
/**
*/
@Test
public void testInsertFromSelectDistinct() {
Map<Integer, Account> accounts = getAccounts(100, 2, 100);
client.cache(CACHE_ACCOUNT).putAll(accounts);
String text = "INSERT INTO \"list\".String (_key, _val) " + "SELECT DISTINCT sn, name FROM \"acc\".Account ";
checkUpdate(client.<Integer, String>cache(CACHE_LIST), null, new SqlFieldsQueryEx(text, false));
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest method testUpdateSetSubquery.
/**
*/
@Test
public void testUpdateSetSubquery() {
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));
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class CacheMvccSqlTxQueriesAbstractTest method testSelectProducesTransaction.
/**
* @throws Exception If failed.
*/
@Test
public void testSelectProducesTransaction() throws Exception {
ccfg = cacheConfiguration(cacheMode(), FULL_SYNC, 2, DFLT_PARTITION_COUNT).setIndexedTypes(Integer.class, MvccTestSqlIndexValue.class);
startGridsMultiThreaded(4);
Random rnd = ThreadLocalRandom.current();
Ignite node = grid(rnd.nextInt(4));
IgniteCache<Object, Object> cache = node.cache(DEFAULT_CACHE_NAME);
SqlFieldsQuery qry = new SqlFieldsQuery("INSERT INTO MvccTestSqlIndexValue (_key, idxVal1) values (1,1),(2,2),(3,3)");
try (FieldsQueryCursor<List<?>> cur = cache.query(qry)) {
assertEquals(3L, cur.iterator().next().get(0));
}
SqlFieldsQueryEx qryEx = new SqlFieldsQueryEx("SELECT * FROM MvccTestSqlIndexValue", true);
qryEx.setAutoCommit(false);
try (FieldsQueryCursor<List<?>> cur = cache.query(qryEx)) {
assertEquals(3, cur.getAll().size());
}
try (GridNearTxLocal tx = cache.unwrap(IgniteEx.class).context().cache().context().tm().userTx()) {
assertNotNull(tx);
}
}
Aggregations