Search in sources :

Example 41 with SqlRow

use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.

the class NotPredicateIntegrationTest method check.

private void check(String operand, Boolean expectedResult, Object... params) {
    String sql = sql(operand);
    List<SqlRow> rows = execute(sql, params);
    assertEquals(1, rows.size());
    SqlRow row = rows.get(0);
    assertEquals(1, row.getMetadata().getColumnCount());
    assertEquals(SqlColumnType.BOOLEAN, row.getMetadata().getColumn(0).getType());
    assertEquals(expectedResult, row.getObject(0));
}
Also used : SqlRow(com.hazelcast.sql.SqlRow)

Example 42 with SqlRow

use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.

the class LikeFunctionIntegrationTest method check.

private void check(String sql, Boolean expectedResult, Object... params) {
    if (negated && expectedResult != null) {
        expectedResult = !expectedResult;
    }
    List<SqlRow> rows = execute(sql, params);
    assertEquals(1, rows.size());
    SqlRow row = rows.get(0);
    assertEquals(1, row.getMetadata().getColumnCount());
    assertEquals(SqlColumnType.BOOLEAN, row.getMetadata().getColumn(0).getType());
    assertEquals(expectedResult, row.getObject(0));
}
Also used : SqlRow(com.hazelcast.sql.SqlRow)

Example 43 with SqlRow

use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.

the class SqlClientCursorCleanupTest method testExceptionOnFetch.

@Test
public void testExceptionOnFetch() {
    IMap<Integer, Person> map = member.getMap(MAP_NAME);
    map.put(0, new Person());
    map.put(1, new Person());
    map.put(2, new Person());
    try {
        SqlResult result = client.getSql().execute(statement());
        for (SqlRow ignore : result) {
            fail = true;
        }
        fail("Must fail");
    } catch (Exception e) {
        assertNoState();
    }
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) SqlResult(com.hazelcast.sql.SqlResult) IOException(java.io.IOException) Test(org.junit.Test)

Example 44 with SqlRow

use of com.hazelcast.sql.SqlRow in project hazelcast by hazelcast.

the class SqlNoDeserializationTest method testMember.

@Test
public void testMember() {
    try (SqlResult res = instance().getSql().execute(SQL)) {
        for (SqlRow row : res) {
            SqlRowImpl row0 = (SqlRowImpl) row;
            row0.getObjectRaw(0);
            row0.getObjectRaw(1);
            checkFailure(row, true);
            checkFailure(row, false);
        }
    }
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) SqlRowImpl(com.hazelcast.sql.impl.SqlRowImpl) SqlResult(com.hazelcast.sql.SqlResult) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 45 with SqlRow

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

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