Search in sources :

Example 1 with UnsortedGrouping

use of org.apache.flink.api.java.operators.UnsortedGrouping in project flink by apache.

the class MaxByOperatorTest method testMaxByRowTypeInfoKeyFieldsForUnsortedGrouping.

/**
 * Validates that no ClassCastException happens should not fail e.g. like in FLINK-8255.
 */
@Test(expected = InvalidProgramException.class)
public void testMaxByRowTypeInfoKeyFieldsForUnsortedGrouping() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    TypeInformation[] types = new TypeInformation[] { Types.INT, Types.INT };
    String[] fieldNames = new String[] { "id", "value" };
    RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames);
    UnsortedGrouping groupDs = env.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo).groupBy(0);
    groupDs.maxBy(1);
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) UnsortedGrouping(org.apache.flink.api.java.operators.UnsortedGrouping) Row(org.apache.flink.types.Row) RowTypeInfo(org.apache.flink.api.java.typeutils.RowTypeInfo) TypeInformation(org.apache.flink.api.common.typeinfo.TypeInformation) Test(org.junit.Test)

Example 2 with UnsortedGrouping

use of org.apache.flink.api.java.operators.UnsortedGrouping in project flink by apache.

the class MinByOperatorTest method testMinByRowTypeInfoKeyFieldsForUnsortedGrouping.

/**
 * Validates that no ClassCastException happens should not fail e.g. like in FLINK-8255.
 */
@Test(expected = InvalidProgramException.class)
public void testMinByRowTypeInfoKeyFieldsForUnsortedGrouping() {
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    TypeInformation[] types = new TypeInformation[] { Types.INT, Types.INT };
    String[] fieldNames = new String[] { "id", "value" };
    RowTypeInfo rowTypeInfo = new RowTypeInfo(types, fieldNames);
    UnsortedGrouping groupDs = env.fromCollection(Collections.singleton(new Row(2)), rowTypeInfo).groupBy(0);
    groupDs.minBy(1);
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) UnsortedGrouping(org.apache.flink.api.java.operators.UnsortedGrouping) Row(org.apache.flink.types.Row) RowTypeInfo(org.apache.flink.api.java.typeutils.RowTypeInfo) TypeInformation(org.apache.flink.api.common.typeinfo.TypeInformation) Test(org.junit.Test)

Aggregations

TypeInformation (org.apache.flink.api.common.typeinfo.TypeInformation)2 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)2 UnsortedGrouping (org.apache.flink.api.java.operators.UnsortedGrouping)2 RowTypeInfo (org.apache.flink.api.java.typeutils.RowTypeInfo)2 Row (org.apache.flink.types.Row)2 Test (org.junit.Test)2