Search in sources :

Example 1 with OBJECT

use of com.hazelcast.sql.SqlColumnType.OBJECT in project hazelcast by hazelcast.

the class BetweenOperatorIntegrationTest method checkValues.

protected void checkValues(String sql, SqlColumnType expectedType, Object[] expectedResults, Object... params) {
    List<SqlRow> rows = execute(sql, params);
    assertEquals(expectedResults.length, rows.size());
    if (rows.size() == 0) {
        return;
    }
    if (rows.get(0).getObject(0) instanceof Integer) {
        rows.sort(Comparator.comparingInt(a -> a.getObject(0)));
    } else if (rows.get(0).getObject(0) instanceof Comparable) {
        rows.sort((a, b) -> ((Comparable<?>) a.getObject(0)).compareTo(b.getObject(0)));
    }
    for (int i = 0; i < expectedResults.length; i++) {
        SqlRow row = rows.get(i);
        assertEquals(expectedType, row.getMetadata().getColumn(0).getType());
        assertEquals(expectedResults[i], row.getObject(0));
    }
}
Also used : SqlRow(com.hazelcast.sql.SqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) INTEGER(com.hazelcast.sql.SqlColumnType.INTEGER) TIME(com.hazelcast.sql.SqlColumnType.TIME) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) LocalDateTime(java.time.LocalDateTime) DOUBLE(com.hazelcast.sql.SqlColumnType.DOUBLE) ExpressionBiValue(com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue) HazelcastSerialClassRunner(com.hazelcast.test.HazelcastSerialClassRunner) ArrayList(java.util.ArrayList) ExpressionTypes(com.hazelcast.jet.sql.impl.support.expressions.ExpressionTypes) LocalTime(java.time.LocalTime) VARCHAR(com.hazelcast.sql.SqlColumnType.VARCHAR) Tuple2(com.hazelcast.jet.datamodel.Tuple2) SqlRow(com.hazelcast.sql.SqlRow) SqlColumnType(com.hazelcast.sql.SqlColumnType) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) OBJECT(com.hazelcast.sql.SqlColumnType.OBJECT) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) BIGINT(com.hazelcast.sql.SqlColumnType.BIGINT) Category(org.junit.experimental.categories.Category) Serializable(java.io.Serializable) ExpressionTestSupport(com.hazelcast.jet.sql.impl.expression.ExpressionTestSupport) List(java.util.List) Tuple2.tuple2(com.hazelcast.jet.datamodel.Tuple2.tuple2) Assert.assertNull(org.junit.Assert.assertNull) Ignore(org.junit.Ignore) LocalDate(java.time.LocalDate) SqlResult(com.hazelcast.sql.SqlResult) ExpressionType(com.hazelcast.jet.sql.impl.support.expressions.ExpressionType) Comparator(java.util.Comparator) DATE(com.hazelcast.sql.SqlColumnType.DATE) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals)

Aggregations

Tuple2 (com.hazelcast.jet.datamodel.Tuple2)1 Tuple2.tuple2 (com.hazelcast.jet.datamodel.Tuple2.tuple2)1 ExpressionTestSupport (com.hazelcast.jet.sql.impl.expression.ExpressionTestSupport)1 ExpressionBiValue (com.hazelcast.jet.sql.impl.support.expressions.ExpressionBiValue)1 ExpressionType (com.hazelcast.jet.sql.impl.support.expressions.ExpressionType)1 ExpressionTypes (com.hazelcast.jet.sql.impl.support.expressions.ExpressionTypes)1 HazelcastSqlException (com.hazelcast.sql.HazelcastSqlException)1 SqlColumnType (com.hazelcast.sql.SqlColumnType)1 BIGINT (com.hazelcast.sql.SqlColumnType.BIGINT)1 DATE (com.hazelcast.sql.SqlColumnType.DATE)1 DOUBLE (com.hazelcast.sql.SqlColumnType.DOUBLE)1 INTEGER (com.hazelcast.sql.SqlColumnType.INTEGER)1 OBJECT (com.hazelcast.sql.SqlColumnType.OBJECT)1 TIME (com.hazelcast.sql.SqlColumnType.TIME)1 VARCHAR (com.hazelcast.sql.SqlColumnType.VARCHAR)1 SqlResult (com.hazelcast.sql.SqlResult)1 SqlRow (com.hazelcast.sql.SqlRow)1 HazelcastSerialClassRunner (com.hazelcast.test.HazelcastSerialClassRunner)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1