Error while importing ArrayType in Glue job

0

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/pyspark.zip/pyspark/sql/functions.py)

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'
已提问 1 年前521 查看次数
1 回答
0
已接受的回答

Issue got resolved for me when I used following imports :

from pyspark.sql.types import ArrayType
from pyspark.sql.types import StringType
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则