1

Spark SQL の助けを借りて、特定のグループ カテゴリに属する​​すべてのビジネス アイテムを除外しようとしています。

データは JSON ファイルからロードされます。

businessJSON = os.path.join(targetDir, 'yelp_academic_dataset_business.json')
businessDF = sqlContext.read.json(businessJSON)

ファイルのスキーマは次のとおりです。

businessDF.printSchema()

root
  |-- business_id: string (nullable = true)
  |-- categories: array (nullable = true)
  |    |-- element: string (containsNull = true)
  ..
  |-- type: string (nullable = true)

レストラン ビジネスに関連するすべてのビジネスを抽出しようとしています。

restaurants = businessDF[businessDF.categories.inSet("Restaurants")]

しかし、予想される列のタイプは文字列である必要があることを理解しているため、機能しませんが、私の場合、これは配列です。それについて私に例外を教えてくれます:

Py4JJavaError: An error occurred while calling o1589.filter.
: org.apache.spark.sql.AnalysisException: invalid cast from string to array<string>;

私が欲しいものを手に入れるための他の方法を提案してもらえますか?

4

1 に答える 1