'15:44 java: incompatible types: org.apache.beam.sdk.values.POutput cannot be converted to org.apache.beam.sdk.values.PCollection
The code below is mostly copy-pasted from the apache beam docs. Still not able to figure out this error. Also, I am trying to learn beam. Can somebody suggest some good tutorial/article to look upon?
import org.apache.beam.sdk.io.TextIO;
import org.apache.beam.sdk.transforms.MapElements;
import org.apache.beam.sdk.transforms.SimpleFunction;
import org.apache.beam.sdk.values.PCollection;
public class reports {
public static void main(String[] args) {
Pipeline p = Pipeline.create();
PCollection<String> students = p.apply(TextIO.read().from("./students.csv"));
// error line below
PCollection output = students.apply(MapElements.via(new calculatePercentage()));
output.apply(TextIO.write().to("./reports.csv"));
p.run();
}
}
class calculatePercentage extends SimpleFunction{
@Override
public Object apply(Object input) {
return input;
}
}```
Solution 1:[1]
Specifying types for SimpleFunction Solved it. ?
class calculatePercentage extends SimpleFunction<String , String>{
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Raj Ghamsani |
