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'
질문됨 일 년 전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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠