You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Thank you for this code, I successfully connected to twitter and received Avro format messages.
I am trying to add to the TweeterStatus information about the original tweet so I added these bold lines to the object TwitterStatus.
`Object TwitterStatus {
def asIso8601String(d:Date) = {
val tz = TimeZone.getTimeZone("UTC")
val df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
df.setTimeZone(tz)
df.format(if (d == null) { new Date() } else { d })
}
Hello,
Thank you for this code, I successfully connected to twitter and received Avro format messages.
I am trying to add to the TweeterStatus information about the original tweet so I added these bold lines to the object TwitterStatus.
`Object TwitterStatus {
def asIso8601String(d:Date) = {
val tz = TimeZone.getTimeZone("UTC")
val df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
df.setTimeZone(tz)
df.format(if (d == null) { new Date() } else { d })
}
def struct(s: twitter4j.Status) =
new Struct(schema)
.put("id", s.getId)
.put("created_at", asIso8601String(s.getCreatedAt))
.put("user", TwitterUser.struct(s.getUser))
.put("text", s.getText)
.put("lang", s.getLang)
.put("is_retweet", s.isRetweet)
.put("retweeted_status", new Struct(schema)
.put("original_tweet_id", s.getRetweetedStatus.getId)
.put("original_user_id", s.getRetweetedStatus.getUser.getId))
.put("entities", Entities.struct(s))
val schema = SchemaBuilder.struct().name("com.eneco.trading.kafka.connect.twitter.Tweet")
.field("id", Schema.INT64_SCHEMA)
.field("created_at", Schema.OPTIONAL_STRING_SCHEMA)
.field("user", TwitterUser.schema)
.field("text", Schema.OPTIONAL_STRING_SCHEMA)
.field("lang", Schema.OPTIONAL_STRING_SCHEMA)
.field("is_retweet", Schema.BOOLEAN_SCHEMA)
.field("retweeted_status",
SchemaBuilder.struct.name("retweeted_status")
.field("original_tweet_id", Schema.OPTIONAL_INT64_SCHEMA).optional()
.field("original_user_id", Schema.OPTIONAL_INT64_SCHEMA).optional().build())
.field("entities", Entities.schema)
.build()
}`
Unfortunately, after various tries I still get an error of NullPointerException.
Would you have any tips about adding information to your schema?
Thanks a lot.
The text was updated successfully, but these errors were encountered: