4

Getting Error : TypeError: 'StructType' object is not callable, while passing StructType to the schema method. Below is the code:

final_schema = StructType([StructField("id", StringType(), True)]) dataframe = sc.read.text('/path').schema(final_schema) 

Data is string type as below:

id AO_01 AO_02 AO_03 
0

1 Answer 1

6

Changed the call to sc.read.schema(final_schema).text('/path') because text(...) will return a dataframe instance and need to set schema before that.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.