Search in sources :

Example 46 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class SqlHashJoinP method join.

private Traverser<JetSqlRow> join(JetSqlRow leftRow) {
    ObjectArrayKey joinKeys = ObjectArrayKey.project(leftRow, joinInfo.leftEquiJoinIndices());
    Collection<JetSqlRow> matchedRows = hashMap.get(joinKeys);
    List<JetSqlRow> output = matchedRows.stream().map(right -> ExpressionUtil.join(leftRow, right, joinInfo.nonEquiCondition(), evalContext)).filter(Objects::nonNull).collect(Collectors.toList());
    if (joinInfo.isLeftOuter() && output.isEmpty()) {
        return Traversers.singleton(leftRow.extendedRow(rightInputColumnCount));
    }
    return Traversers.traverseIterable(output);
}
Also used : ObjectArrayKey(com.hazelcast.jet.sql.impl.ObjectArrayKey) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 47 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class SqlTestSupport method compareRowLists.

/**
 * Compares two lists. The lists are expected to contain elements of type
 * Object[]. Useful for {@link TestSupport#outputChecker(BiPredicate)}.
 */
public static boolean compareRowLists(List<?> expected, List<?> actual) {
    if (expected.size() != actual.size()) {
        return false;
    }
    for (int i = 0; i < expected.size(); i++) {
        JetSqlRow expectedItem = (JetSqlRow) expected.get(i);
        JetSqlRow actualItem = (JetSqlRow) actual.get(i);
        if (!Objects.equals(expectedItem, actualItem)) {
            return false;
        }
    }
    return true;
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 48 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class ExpressionUtilTest method test_join.

private void test_join(Expression<Boolean> predicate, Object[] leftRow, Object[] rightRow, Object[] expected) {
    JetSqlRow joined = ExpressionUtil.join(new JetSqlRow(TEST_SS, leftRow), new JetSqlRow(TEST_SS, rightRow), predicate, createExpressionEvalContext());
    assertThat(joined == null ? null : joined.getValues()).isEqualTo(expected);
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 49 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class WindowUtilsTest method check_addWindowBounds.

/**
 * Calls WindowUtils.addWindowBounds with a record with the given
 * {@code timestamp} and window policy. Asserts that the returned
 * traverser contains the given {@code outputWindows}.
 */
private void check_addWindowBounds(Object timestamp, long windowSize, long slideBy, Object... outputWindows) {
    // noinspection SimplifiableAssertion
    assertTrue(outputWindows.length % 2 == 0);
    Traverser<JetSqlRow> traverser = WindowUtils.addWindowBounds(new JetSqlRow(TEST_SS, new Object[] { timestamp }), 0, slidingWinPolicy(windowSize, slideBy));
    for (int i = 0; i < outputWindows.length; i += 2) {
        Object[] expected = new Object[] { timestamp, outputWindows[i], outputWindows[i + 1] };
        assertArrayEquals(expected, traverser.next().getValues());
    }
    assertNull(traverser.next());
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow)

Example 50 with JetSqlRow

use of com.hazelcast.sql.impl.row.JetSqlRow in project hazelcast by hazelcast.

the class SqlMetadataTest method testRow.

@Test
public void testRow() {
    SqlColumnMetadata column0Metadata = new SqlColumnMetadata("a", SqlColumnType.INTEGER, true);
    SqlColumnMetadata column1Metadata = new SqlColumnMetadata("b", SqlColumnType.VARCHAR, true);
    SqlRow row = new SqlRowImpl(new SqlRowMetadata(Arrays.asList(column0Metadata, column1Metadata)), new JetSqlRow(TEST_SS, new Object[] { 1, "2" }));
    assertEquals("[a INTEGER=1, b VARCHAR=2]", row.toString());
}
Also used : JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) SqlRowImpl(com.hazelcast.sql.impl.SqlRowImpl) JetSqlRow(com.hazelcast.sql.impl.row.JetSqlRow) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JetSqlRow (com.hazelcast.sql.impl.row.JetSqlRow)50 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)16 QuickTest (com.hazelcast.test.annotation.QuickTest)16 Test (org.junit.Test)16 ExpressionEvalContext (com.hazelcast.sql.impl.expression.ExpressionEvalContext)15 ArrayList (java.util.ArrayList)14 Vertex (com.hazelcast.jet.core.Vertex)13 List (java.util.List)9 IndexConfig (com.hazelcast.config.IndexConfig)8 JobConfig (com.hazelcast.jet.config.JobConfig)8 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)8 NodeEngine (com.hazelcast.spi.impl.NodeEngine)8 Expression (com.hazelcast.sql.impl.expression.Expression)8 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)8 FunctionEx (com.hazelcast.function.FunctionEx)7 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)7 DAG (com.hazelcast.jet.core.DAG)6 ObjectArrayKey (com.hazelcast.jet.sql.impl.ObjectArrayKey)6 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)5 Traverser (com.hazelcast.jet.Traverser)5