我有一个嵌套的json rdd流,它来自一个Kafka主题。数据如下所示:
{
"time":"sometext1","host":"somehost1","event":
{"category":"sometext2","computerName":"somecomputer1"}
}
我把它转换成一个Dataframe,模式看起来像
root
|-- event: struct (nullable = true)
| |-- category: string (nullable = true)
| |-- computerName: string (nullable = true)
|-- time: string (nullable = true)
|-- host: string (nullable = true)
我试图用这样的模式将它保存到hdfs上的配置单元表中
category:string
computerName:string
time:string
host:string
这是我第一次使用spark和scala。如果有人能帮助我,我将不胜感激。谢谢
1条答案
按热度按时间eqoofvh91#
jsondf.printschema
df.printschema格式
测向显示