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 年前檢視次數 545 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南