Error while importing ArrayType in Glue job


from pyspark.sql.functions import ArrayType

For this I am getting error in Glue job. Glue Version I am using is 3.0 which supports spark 3.1

ImportError: cannot import name 'ArrayType' from 'pyspark.sql.functions' (/opt/amazon/spark/python/lib/

On using next Glue version Glue 4.0 with spark 3.3 getting another error

 from pyspark.sql.functions import ArrayType 
from pyspark.sql.functions import StringType

class JobBase(object):
    #all udf has to be initialised as first step 
    def __init__(self):
        print("Inside the constructor of Class phases ")

        self.winner_org_calculation_udf=udf(JobBase.winner_org_calculation, ArrayType(StringType()))
TypeError: ArrayType.__init__() missing 1 required positional argument: 'elementType'
asked 7 days ago13 views
1 Answer
Accepted Answer

Issue got resolved for me when I used following imports :

from pyspark.sql.types import ArrayType
from pyspark.sql.types import StringType
answered 7 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions