添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request. We’ll get back to you as soon as possible.

Please enter the details of your request. A member of our support staff will respond as soon as possible.

Problem

You are selecting columns from a DataFrame and you get an error message.

ERROR: AttributeError: 'function' object has no attribute '_get_object_id' in job

Cause

The DataFrame API contains a small number of protected keywords.

If a column in your DataFrame uses a protected keyword as the column name, you will get an error message.

For example, summary is a protected keyword. If you use summary as a column name, you will see the error message.

This sample code uses summary as a column name and generates the error message when run.

%python
df=spark.createDataFrame([1,2], "int").toDF("id")
df.show()
from pyspark.sql.types import StructType,StructField, StringType, IntegerType
df1 = spark.createDataFrame(
  [(10,), (11,), (13,)],
  StructType([StructField("summary", IntegerType(), True)]))
df1.show()
ResultDf = df1.join(df, df1.summary == df.id, "inner").select(df.id,df1.summary)
ResultDf.show()

Solution

You should not use DataFrame API protected keywords as column names.

If you must use protected keywords, you should use bracket based column access when selecting columns from a DataFrame. Do not use dot notation when selecting columns that use protected keywords.

%python
ResultDf = df1.join(df, df1["summary"] == df.id, "inner").select(df.id,df1["summary"])