簡體   English   中英

Pyspark StructType 未定義

[英]Pyspark StructType is not defined

我正在嘗試為 db 測試構建一個架構,而 StructType 顯然由於某種原因無法正常工作。 我正在關注 tut,它沒有導入任何額外的模塊。

<type 'exceptions.NameError'>, NameError("name 'StructType' is not defined",), <traceback object at 0x2b555f0>)

我在 spark 1.4.0 和 Ubuntu 12 上,如果這與問題有關的話。 我將如何解決這個問題? 先感謝您。

你導入了StructType嗎? 如果不

from pyspark.sql.types import StructType

應該可以解決問題。

from pyspark.sql.types import StructType

那會解決它,但接下來你可能會得到NameError: name 'IntegerType' is not definedNameError: name 'StringType' is not defined ..

為了避免所有這些,只需執行以下操作:

from pyspark.sql.types import *

或者,一一導入您需要的所有類型:

from pyspark.sql.types import StructType, IntegerType, StringType

所有類型: Apache Spark 數據類型

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM