[BUG] Spark can't start read stream- NullPointerException in pulsar-spark-connector V3.1.1.2
AshiSaraswat opened this issue · 2 comments
AshiSaraswat commented
Describe the bug
While trying to start spark structured streaming read stream, connector throws NullPointerException.
pulsar-connector jar - “io.streamnative.connectors:pulsar-spark-connector_2.12:3.1.1.2”
PySpark version = 3.1.2
python version = 3.7
Code snippet throwing error is-
eventsDF = spark_session.readStream \
.format("pulsar") \
.option("service.url", service_url) \
.option("admin.url", admin_url) \
.option("topics", topic) \
.option("subscriptionprefix", "nlu-test") \
.load() \
.selectExpr("CAST(value AS STRING)") \
.select(from_json("value",schema_item).alias("event")) \
.select("event.*").repartition(partitions)
Error Trace is -
Traceback (most recent call last):
File "/Users/ashi/MyDev/workspace/src/post_call_etl_job/main_local.py", line 361, in <module>
compute_df = pci.events_queueDF(spark, topic_compute, schema, partition_count)
File "/Users/ashi/MyDev/workspace/src/post_call_etl_job/main_local.py", line 102, in events_queueDF
.option("subscriptionprefix", "nlu-test") \
File "/Users/ashi/MyDev/workspace/.venv/lib/python3.7/site-packages/pyspark/sql/streaming.py", line 482, in load
return self._df(self._jreader.load())
File "/Users/ashi/MyDev/workspace/.venv/lib/python3.7/site-packages/py4j/java_gateway.py", line 1305, in __call__
answer, self.gateway_client, self.target_id, self.name)
File "/Users/ashi/MyDev/workspace/.venv/lib/python3.7/site-packages/pyspark/sql/utils.py", line 111, in deco
return f(*a, **kw)
File "/Users/ashi/MyDev/workspace/.venv/lib/python3.7/site-packages/py4j/protocol.py", line 328, in get_return_value
format(target_id, ".", name), value)
py4j.protocol.Py4JJavaError: An error occurred while calling o63.load.
: java.lang.NullPointerException
at org.apache.spark.sql.pulsar.PulsarMetadataReader.getPulsarSchema(PulsarMetadataReader.scala:170)
at org.apache.spark.sql.pulsar.PulsarMetadataReader.getSchema(PulsarMetadataReader.scala:164)
at org.apache.spark.sql.pulsar.PulsarMetadataReader.getAndCheckCompatible(PulsarMetadataReader.scala:148)
at org.apache.spark.sql.pulsar.PulsarProvider.$anonfun$sourceSchema$2(PulsarProvider.scala:71)
at org.apache.spark.util.Utils$.tryWithResource(Utils.scala:2622)
at org.apache.spark.sql.pulsar.PulsarProvider.sourceSchema(PulsarProvider.scala:70)
at org.apache.spark.sql.execution.datasources.DataSource.sourceSchema(DataSource.scala:236)
at org.apache.spark.sql.execution.datasources.DataSource.sourceInfo$lzycompute(DataSource.scala:117)
at org.apache.spark.sql.execution.datasources.DataSource.sourceInfo(DataSource.scala:117)
at org.apache.spark.sql.execution.streaming.StreamingRelation$.apply(StreamingRelation.scala:33)
at org.apache.spark.sql.streaming.DataStreamReader.loadInternal(DataStreamReader.scala:219)
at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Thread.java:748)
To Reproduce
Steps to reproduce the behavior:
- Run apache pulsar docker container (apachepulsar/pulsar:2.6.1)
- Use pulsar python client to send message to persistent topic.
- Start spark streaming app. I load pulsar connector library in spark app code.
- As soon as it tries to parse options and create data steam, I get error.
Expected behavior
Spark should be able to create read stream.
@nlu90 - for your kind attention.
syhily commented
We can't reproduce this exception. So we will close it.