use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.
the class PositionFunctionIntegrationTest method check.
private void check(String sql, Integer expectedResult, Object... parameters) {
List<SqlRow> rows = execute(sql, parameters);
assertEquals("size", 1, rows.size());
SqlRow row = rows.get(0);
assertEquals(SqlColumnType.INTEGER, row.getMetadata().getColumn(0).getType());
assertEquals(expectedResult, row.getObject(0));
}
use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.
the class ReplaceFunctionIntegrationTest method check.
private void check(String sql, String expectedResult) {
List<SqlRow> rows = execute(sql, null);
assertGreaterOrEquals("size must be greater than 0", rows.size(), 0);
SqlRow row = rows.get(0);
assertEquals(SqlColumnType.VARCHAR, row.getMetadata().getColumn(0).getType());
assertEquals(expectedResult, row.getObject(0));
}
use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.
the class SqlJsonTestSupport method query.
public static List<Map<String, Object>> query(final String sql) {
final List<Map<String, Object>> results = new ArrayList<>();
for (final SqlRow row : instance().getSql().execute(sql)) {
final Map<String, Object> result = new HashMap<>();
final SqlRowMetadata rowMetadata = row.getMetadata();
for (int i = 0; i < rowMetadata.getColumnCount(); i++) {
result.put(rowMetadata.getColumn(i).getName(), row.getObject(i));
}
results.add(result);
}
return results;
}
use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.
the class SqlClientPortableQueryTest method testNestedPortableAsColumn.
@Test
public void testNestedPortableAsColumn() {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getSerializationConfig().addPortableFactory(PORTABLE_FACTORY_ID, new TestPortableFactory());
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
createMapping(client, "test", int.class, PORTABLE_FACTORY_ID, PORTABLE_PARENT_CLASS_ID, 0);
IMap<Integer, ParentPortable> map = client.getMap("test");
fillMap(map, 100, ParentPortable::new);
SqlResult result = client.getSql().execute("SELECT id, child FROM test WHERE id = ? ", 1);
SqlRow row = Iterators.getOnlyElement(result.iterator());
assertEquals((Integer) 1, row.getObject(0));
assertEquals(new ChildPortable(1), row.getObject(1));
}
use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.
the class SqlClientTest method test_jetJobReturnRowsToClientFrom.
@Test
public void test_jetJobReturnRowsToClientFrom() {
HazelcastInstance client = factory().newHazelcastClient();
SqlService sqlService = client.getSql();
int itemCount = 10_000;
TestBatchSqlConnector.create(sqlService, "t", itemCount);
SqlResult result = sqlService.execute("SELECT v FROM t");
BitSet seenValues = new BitSet(itemCount);
for (SqlRow r : result) {
Integer v = r.getObject(0);
assertFalse("value already seen: " + v, seenValues.get(v));
seenValues.set(v);
}
assertEquals(itemCount, seenValues.cardinality());
}
Aggregations