Hello. I am trying to use the CountVectorizer module as part of our feature engineering. It works on a Databricks notebook directly, but when I try to run the code through Azure with the databricks connection, it throws an error. This isn't the first time I've had an issue with CountVectorizer. The weirdest part is that this same code has worked until last Thursday (07/28). I have tried the following which has solved previous issues.
- Launching a new clean cluster
- Changing spark.serializer back to default, since kyro serializer was causing issues
- Changing various spark-defaults.conf
Some things my searches have suggested that I haven't tried yet
- Reverting Java 11 -> Java 8
- Python Serializers
Thank you in advance for your help!
Code:
from pyspark.ml.feature import CountVectorizer
df = spark.createDataFrame([
("A", ['a','b']),
("B", ['a']),
("C", ['a','b','c']),
("D", ['d']),
("E", ['a','b','c']),
], ['ID','Category'])
cv = CountVectorizer(inputCol='Category',outputCol='vectors')
model = cv.fit(df)
model.transform(df).show()
Console Output & Error:
22/08/01 13:10:39 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/jars/spark-unsafe_2.12-3.1.1-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
22/08/01 13:10:40 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
22/08/01 13:10:41 WARN MetricsSystem: Using default name SparkStatusTracker for source because neither spark.metrics.namespace nor spark.app.id is set.
Traceback (most recent call last):
File "test_sparse_adb_bare.py", line 14, in <module>
model = cv.fit(df)
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/base.py", line 161, in fit
return self._fit(dataset)
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/wrapper.py", line 335, in _fit
java_model = self._fit_java(dataset)
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/ml/wrapper.py", line 332, in _fit_java
return self._java_obj.fit(dataset._jdf)
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/py4j/java_gateway.py", line 1304, in __call__
return_value = get_return_value(
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/pyspark/sql/utils.py", line 117, in deco
return f(*a, **kw)
File "/anaconda/envs/major_medical_env_adb_py38/lib/python3.8/site-packages/py4j/protocol.py", line 326, in get_return_value
raise Py4JJavaError(
py4j.protocol.Py4JJavaError: An error occurred while calling o41.fit.
: java.io.StreamCorruptedException: invalid type code: 01