use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlIndexConverterMismatchTest method testMismatch.
/**
* @see MapIndexScanExecIterator#getIndexEntries
*/
@SuppressWarnings({ "StatementWithEmptyBody", "JavadocReference" })
@Ignore("https://github.com/hazelcast/hazelcast/issues/19287")
@Test
public void testMismatch() {
ExpressionBiValue value1 = new ExpressionBiValue.IntegerIntegerVal();
value1.field1(10);
value1.field2(10);
ExpressionBiValue value2 = new ExpressionBiValue.StringIntegerVal();
value2.field1("10");
value2.field2(10);
map.put(getLocalKey(member1, key -> key), value1);
map.put(getLocalKey(member2, key -> key), value2);
try {
try (SqlResult result = member1.getSql().execute("SELECT key FROM " + MAP_NAME + " WHERE field1=1")) {
for (SqlRow ignore : result) {
// No-op.
}
}
fail("Must fail!");
} catch (HazelcastSqlException e) {
assertEquals(SqlErrorCode.INDEX_INVALID, e.getCode());
Throwable ex = findRootQueryException(e);
assertEquals("Cannot use the index \"index\" of the IMap \"map\" because it has component \"field1\" of type VARCHAR, but INTEGER was expected", ex.getMessage());
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlClientCursorCleanupTest method testExceptionOnFetch.
@Test
public void testExceptionOnFetch() {
IMap<Integer, Person> map = member.getMap(MAP_NAME);
map.put(0, new Person());
map.put(1, new Person());
map.put(2, new Person());
try {
SqlResult result = client.getSql().execute(statement());
for (SqlRow ignore : result) {
fail = true;
}
fail("Must fail");
} catch (Exception e) {
assertNoState();
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlNoDeserializationTest method testMember.
@Test
public void testMember() {
try (SqlResult res = instance().getSql().execute(SQL)) {
for (SqlRow row : res) {
SqlRowImpl row0 = (SqlRowImpl) row;
row0.getObjectRaw(0);
row0.getObjectRaw(1);
checkFailure(row, true);
checkFailure(row, false);
}
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlNoSerializationTest method check.
private void check(String sql, boolean expectedIndexUsage) {
checkIndexUsage(new SqlStatement(sql), expectedIndexUsage);
try (SqlResult res = instance().getSql().execute(sql)) {
int count = 0;
for (SqlRow row : res) {
Object key = row.getObject(0);
Object value = row.getObject(1);
assertTrue(key instanceof Key);
assertTrue(value instanceof Value);
count++;
}
assertEquals(1, count);
}
}
use of com.hazelcast.sql.SqlResult in project hazelcast by hazelcast.
the class SqlSecurityCallbackTest method check.
private void check(String sql, boolean useIndex) {
// Execute twice to make sure that permission is checked when the plan is cached.
for (int i = 0; i < 2; i++) {
TestSqlSecurityContext securityContext = new TestSqlSecurityContext();
try (SqlResult ignored = ((SqlServiceImpl) instance().getSql()).execute(new SqlStatement(sql), securityContext)) {
// Check whether the index is used as expected.
checkIndexUsage(sql, useIndex);
// Check permissions.
assertThat(securityContext.getPermissions()).contains(new MapPermission(mapName, ActionConstants.ACTION_READ));
}
}
}
Aggregations