use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class SqlErrorAbstractTest method checkDataTypeMismatch.
protected void checkDataTypeMismatch(boolean useClient) {
// Start two instances and fill them with data
instance1 = newHazelcastInstance(false);
instance2 = newHazelcastInstance(true);
client = newClient();
IMap<Long, Object> map = instance1.getMap(MAP_NAME);
createMapping(instance1, MAP_NAME, long.class, long.class);
for (long i = 0; i < DATA_SET_SIZE; i++) {
Object value = i == 0 ? Long.toString(i) : i;
map.put(i, value);
}
// Execute query.
HazelcastSqlException error = assertSqlException(useClient ? client : instance1, query());
assertErrorCode(SqlErrorCode.DATA_EXCEPTION, error);
assertTrue(error.getMessage().contains("Failed to extract map entry value because of type mismatch " + "[expectedClass=java.lang.Long, actualClass=java.lang.String]"));
}
use of com.hazelcast.sql.HazelcastSqlException 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.HazelcastSqlException in project hazelcast by hazelcast.
the class SqlErrorAbstractTest method checkUserCancel.
@SuppressWarnings("StatementWithEmptyBody")
protected void checkUserCancel(boolean useClient) {
instance1 = newHazelcastInstance(true);
client = newClient();
HazelcastInstance target = useClient ? client : instance1;
try (SqlResult res = target.getSql().execute("select * from table(generate_stream(1))")) {
sleepSeconds(1);
res.close();
try {
for (SqlRow ignore : res) {
// No-op.
}
fail("Exception is not thrown");
} catch (HazelcastSqlException e) {
assertErrorCode(SqlErrorCode.CANCELLED_BY_USER, e);
}
}
}
use of com.hazelcast.sql.HazelcastSqlException 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"));
}
use of com.hazelcast.sql.HazelcastSqlException in project hazelcast by hazelcast.
the class SqlClientService method handleFetchResponse.
private void handleFetchResponse(Connection connection, SqlClientResult res, ClientMessage message, Throwable error) {
if (error != null) {
res.onFetchFinished(null, rethrow(error, connection));
return;
}
SqlFetchCodec.ResponseParameters responseParameters = SqlFetchCodec.decodeResponse(message);
HazelcastSqlException responseError = handleResponseError(responseParameters.error);
if (responseError != null) {
res.onFetchFinished(null, responseError);
return;
}
assert responseParameters.rowPage != null;
res.onFetchFinished(responseParameters.rowPage, null);
}
Aggregations