use of com.hazelcast.sql.impl.SqlServiceImpl in project hazelcast by hazelcast.
the class SqlSchemaPropagationTest method check.
private void check(HazelcastInstance target) {
// Set the wrapped optimizer to track optimization requests.
SqlServiceImpl service = (SqlServiceImpl) instance().getSql();
// Execute the query from the target without schema.
SqlStatement statement = new SqlStatement("SELECT __key FROM map");
List<SqlRow> rows = executeStatement(target, statement);
assertEquals(1, rows.size());
assertEquals(1, (int) rows.get(0).getObject(0));
assertEquals(1, service.getPlanCache().size());
List<List<String>> originalSearchPaths = Iterables.getOnlyElement(extractSearchPaths());
// Execute the query from the target with schema.
statement.setSchema(SCHEMA_NAME);
rows = executeStatement(target, statement);
assertEquals(1, rows.size());
assertEquals(1, (int) rows.get(0).getObject(0));
assertEquals(2, service.getPlanCache().size());
List<List<List<String>>> searchPaths = extractSearchPaths();
List<List<String>> expectedSearchPaths = new ArrayList<>(originalSearchPaths);
expectedSearchPaths.add(0, asList(CATALOG, SCHEMA_NAME));
assertThat(searchPaths).containsExactlyInAnyOrder(originalSearchPaths, expectedSearchPaths);
}
use of com.hazelcast.sql.impl.SqlServiceImpl in project hazelcast by hazelcast.
the class OptimizerInstantiationTest method testCreate.
@Test
public void testCreate() {
SqlServiceImpl service = ((HazelcastInstanceProxy) instance()).getOriginal().node.getNodeEngine().getSqlService();
SqlOptimizer optimizer = service.getOptimizer();
assertNotNull(optimizer);
assertEquals(CalciteSqlOptimizer.class, optimizer.getClass());
}
use of com.hazelcast.sql.impl.SqlServiceImpl in project hazelcast by hazelcast.
the class SqlClientCursorCleanupTest method assertNoState.
private void assertNoState() {
SqlInternalService service = ((SqlServiceImpl) member.getSql()).getInternalService();
assertEquals(0, service.getResultRegistry().getResultCount());
assertEquals(0, service.getClientStateRegistry().getCursorCount());
}
use of com.hazelcast.sql.impl.SqlServiceImpl in project hazelcast by hazelcast.
the class PhoneHomeTest method testSqlQueriesSubmitted.
@Test
public void testSqlQueriesSubmitted() {
Map<String, String> parameters = phoneHome.phoneHome(true);
assertEquals(parameters.get(PhoneHomeMetrics.SQL_QUERIES_SUBMITTED.getRequestParameterName()), "0");
SqlServiceImpl sqlService = node.getNodeEngine().getSqlService();
try {
sqlService.execute("SELECT * FROM map");
} catch (Exception e) {
ignore(e);
}
parameters = phoneHome.phoneHome(true);
assertEquals(parameters.get(PhoneHomeMetrics.SQL_QUERIES_SUBMITTED.getRequestParameterName()), "1");
}
use of com.hazelcast.sql.impl.SqlServiceImpl 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