在Glue作业中导入ArrayType时出现错误。

0

【以下的问题经过翻译处理】 我在Glue工作中遇到了错误。 我使用的Glue版本是3.0,支持spark 3.1。

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

在使用Glue 4.0和spark 3.3时,遇到了另一个错误。

 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'

profile picture
エキスパート
質問済み 5ヶ月前19ビュー
1回答
0

【以下的回答经过翻译处理】 使用以下导入时,我的问题得到了解决:

from pyspark.sql.types import ArrayType
from pyspark.sql.types import StringType

profile picture
エキスパート
回答済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ