Github user obaidcuet commented on the pull request:
https://github.com/apache/spark/pull/9360#issuecomment-216732472
Hi,
Just FYI.
Hope it may be helpful for someone.
I had exactly same issue while reading twitter data from Kafka (collected
using flume).
I have no idea where those non-UTF8 data coming from. The should be
rejected by flume itself.
However, I do not need those special characters and used below to ignore
them:
## create a decoder function with parameter "ignore"
def utf8_decoder_ignore_error(s):
""" Decode the unicode as UTF-8 """
if s is None:
return None
return s.decode('utf-8', "ignore")
## then use that decoder in createDirectStream as below
kvs = KafkaUtils.createDirectStream(ssc, [topic], {"metadata.broker.list":
brokers}, keyDecoder=utf8_decoder_ignore_error,
valueDecoder=utf8_decoder_ignore_error )
-Obaid
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]