Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-2135

Java plan translation fails with ClassCastException (probably in first())

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: 0.9
    • Component/s: None
    • Labels:
      None

      Description

      A user reported the following error

      Exception in thread "main" java.lang.ClassCastException: org.apache.flink.api.java.functions.FirstReducer cannot be cast to org.apache.flink.api.common.functions.RichGroupReduceFunction
      	at org.apache.flink.api.java.operators.translation.PlanUnwrappingSortedReduceGroupOperator.<init>(PlanUnwrappingSortedReduceGroupOperator.java:40)
      	at org.apache.flink.api.java.operators.GroupReduceOperator.translateSelectorFunctionSortedReducer(GroupReduceOperator.java:278)
      	at org.apache.flink.api.java.operators.GroupReduceOperator.translateToDataFlow(GroupReduceOperator.java:177)
      	at org.apache.flink.api.java.operators.GroupReduceOperator.translateToDataFlow(GroupReduceOperator.java:50)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translateSingleInputOperator(OperatorTranslation.java:124)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translate(OperatorTranslation.java:86)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translateSingleInputOperator(OperatorTranslation.java:122)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translate(OperatorTranslation.java:86)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translateSingleInputOperator(OperatorTranslation.java:122)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translate(OperatorTranslation.java:86)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translate(OperatorTranslation.java:61)
      	at org.apache.flink.api.java.operators.OperatorTranslation.translateToPlan(OperatorTranslation.java:49)
      	at org.apache.flink.api.java.ExecutionEnvironment.createProgramPlan(ExecutionEnvironment.java:925)
      	at org.apache.flink.api.java.ExecutionEnvironment.createProgramPlan(ExecutionEnvironment.java:893)
      	at org.apache.flink.api.java.LocalEnvironment.execute(LocalEnvironment.java:50)
      	at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:789)
      	at org.apache.flink.api.java.DataSet.collect(DataSet.java:411)
      	at org.apache.flink.api.java.DataSet.print(DataSet.java:1346)
      	at com.dataartisans.GroupReduceBug.main(GroupReduceBug.java:43)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
      

      It is reproducible with the following code

      		ExecutionEnvironment ee = ExecutionEnvironment.getExecutionEnvironment();
      
      		DataSet<String> b = ee.fromElements("a", "b");
      		GroupReduceOperator<String, String> a = b.groupBy(new KeySelector<String, Long>() {
      			@Override
      			public Long getKey(String value) throws Exception {
      				return 1L;
      			}
      		}).sortGroup(new KeySelector<String, Double>() {
      			@Override
      			public Double getKey(String value) throws Exception {
      				return 1.0;
      			}
      		}, Order.DESCENDING).first(10);
      
      		a.print();
      

        Attachments

          Activity

            People

            • Assignee:
              rmetzger Robert Metzger
              Reporter:
              rmetzger Robert Metzger
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: