use of com.hazelcast.sql.SqlStatement in project hazelcast by hazelcast.
the class SqlIndexCastTest method checkIsNull.
private void checkIsNull(ExpressionType<?> typeFrom, QueryDataTypeFamily typeTo, boolean expectedIndexUsage) {
String sql = "SELECT field1 FROM " + MAP_NAME + " WHERE CAST(field1 AS " + typeTo + ") IS NULL";
checkIndexUsage(new SqlStatement(sql), typeFrom, expectedIndexUsage);
}
use of com.hazelcast.sql.SqlStatement 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.SqlStatement 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));
}
}
}
use of com.hazelcast.sql.SqlStatement in project hazelcast by hazelcast.
the class SqlErrorAbstractTest method checkParsingError.
protected void checkParsingError(boolean useClient) {
instance1 = newHazelcastInstance(true);
client = newClient();
createMapping(instance1, MAP_NAME, long.class, long.class);
IMap<Long, Long> map = instance1.getMap(MAP_NAME);
map.put(1L, 1L);
HazelcastInstance target = useClient ? client : instance1;
HazelcastSqlException error = assertSqlException(target, new SqlStatement("SELECT bad_field FROM " + MAP_NAME));
assertErrorCode(SqlErrorCode.PARSING, error);
}
use of com.hazelcast.sql.SqlStatement in project hazelcast by hazelcast.
the class SqlErrorClientTest method testParameterError_serialization.
@Test
public void testParameterError_serialization() {
instance1 = newHazelcastInstance(true);
client = newClient();
SqlStatement query = new SqlStatement("SELECT * FROM map").addParameter(new BadParameter(true, false));
HazelcastSqlException error = assertSqlException(client, query);
assertErrorCode(SqlErrorCode.GENERIC, error);
assertTrue(error.getMessage().contains("Failed to serialize query parameter"));
}
Aggregations