我在java中使用spark,并从row的rdd创建一个row数据集。
我使用
Metadata meta = new MetadataBuilder().putString("type", "categorical").build();
StructField s = new StructField(name, IntegerType, true, meta);
StructType t = new StructType(new StructField[]{s});
Encoder<Row> encoder = RowEncoder.apply(t);
我在数据集中这样使用它
ds.flatMap((FlatMapFunction<Row, Row>) this::customFlatMapRow, encoder);
由于某些原因,在我编写表并检查模式的字段及其元数据之后,它们是空的(尽管事实上我是这样创建和设置它们的)。不知怎的,我把它们弄丢了
1条答案
按热度按时间cld4siwp1#
如果检查数据集的expressionencoder,则元数据可用。
代码
印刷品