带有结构化火花流的Twitter API

发布于 2025-01-26 11:27:44 字数 46 浏览 5 评论 0 原文

我正在尝试从我的kafka主题中的Tweet访问JSON数据。像文本字段一样?

I am trying to access the json data from tweets in my kafka topic.In my spark structured streaming while creating schema is it necessary to explicitly specify each and every key from the twitter API.Can i not access the only ones which i want to analyse like the text field alone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你再特殊 2025-02-02 11:27:44

虽然推荐,但该模式是可选的。您应该能够做这样的事情

kafkaDf
    .select(col("value").cast("string").as("value")) 
    .select(get_json_object(col("value"), "$.text"))

While recommended, the schema is optional. You should be able to do something like this

kafkaDf
    .select(col("value").cast("string").as("value")) 
    .select(get_json_object(col("value"), "$.text"))

https://spark.apache.org/docs/latest/api/sql/index.html#get_json_object

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文