Dataset<Tweet> ds = sc.read().json("/path").as(Encoders.bean(Tweet.class));
Tweet class :-
long id
string user;
string text;
ds.printSchema();
Run Code Online (Sandbox Code Playgroud)
输出:-
root
|-- id: string (nullable = true)
|-- text: string (nullable = true)
|-- user: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
json文件具有字符串类型的所有参数
我的问题是接受输入并将其编码为Tweet.class。模式中为id指定的数据类型为Long,但在打印模式时将其强制转换为String。
它是否为printscheme a / c提供了读取文件的方式或根据我们所做的编码(此处为Tweet.class)?