第一种方法
List<Row> tmpList = new ArrayList<Row>() {
{
add(row1);
add(row2);
}
};
Seq<Row> tmpSeq =JavaConverters.asScalaIteratorConverter(tmpList.iterator()).asScala().toSeq();
Row resultRow = Row.merge(tmpSeq);
第二种方法
private Row mergeRowColumn(Row mRow, Row objRow, String column,String type, Long value) {
List<Long> tmpList = new ArrayList<Long>() {
{
add(value != null ? value : mRow.getAs(column));
}
};
StructType schema = objRow.schema().add(column, type);
GenericRowWithSchema newRow = new GenericRowWithSchema(tmpList.toArray(), schema);
return newRow;
}