I would like to write an encoder for a Row type in DataSet, for a map operation that I am doing. Essentially, I do not understand how to write encoders.
Below is an exam
The answer is to use a RowEncoder and the schema of the dataset using StructType.
Below is a working example of a flatmap operation with Datasets:
StructType structType = new StructType();
structType = structType.add("id1", DataTypes.LongType, false);
structType = structType.add("id2", DataTypes.LongType, false);
ExpressionEncoder encoder = RowEncoder.apply(structType);
Dataset output = join.flatMap(new FlatMapFunction() {
@Override
public Iterator call(Row row) throws Exception {
// a static map operation to demonstrate
List