Search in sources :

Example 46 with SqlRow

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));
}
Also used : SqlRow(com.hazelcast.sql.SqlRow)

Example 47 with SqlRow

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));
}
Also used : SqlRow(com.hazelcast.sql.SqlRow)

Example 48 with SqlRow

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;
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 49 with SqlRow

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));
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SqlResult(com.hazelcast.sql.SqlResult) ClientConfig(com.hazelcast.client.config.ClientConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 50 with SqlRow

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());
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SqlResult(com.hazelcast.sql.SqlResult) SqlService(com.hazelcast.sql.SqlService) BitSet(java.util.BitSet) Test(org.junit.Test)

Aggregations

SqlRow (com.hazelcast.sql.SqlRow)65 Test (org.junit.Test)35 SqlResult (com.hazelcast.sql.SqlResult)29 QuickTest (com.hazelcast.test.annotation.QuickTest)25 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)17 SqlRowMetadata (com.hazelcast.sql.SqlRowMetadata)13 HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)11 ArrayList (java.util.ArrayList)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)8 SqlStatement (com.hazelcast.sql.SqlStatement)7 SqlService (com.hazelcast.sql.SqlService)5 HashSet (java.util.HashSet)5 SqlColumnType (com.hazelcast.sql.SqlColumnType)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 Config (com.hazelcast.config.Config)2 IndexConfig (com.hazelcast.config.IndexConfig)2 HazelcastException (com.hazelcast.core.HazelcastException)2 ExpressionBiValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)2 IMap (com.hazelcast.map.IMap)2 SqlColumnMetadata (com.hazelcast.sql.SqlColumnMetadata)2