I read in a parquet file from S3 in databricks using the following command
df = sqlContext.read.parquet('s3://path/to/parquet/file')
I want to read the schema of the dataframe, which I can do using the following command:
df_schema = df.schema.json()
But I am not able to write the df_schama object to a file on S3.
Note: I am open to not creating a json file. I just want to save the schema of the dataframe to any file type (possibly a text file) in AWS S3.
I have tried writing the json schema as follows,
df_schema.write.csv("s3://path/to/file")
or
a.write.format('json').save('s3://path/to/file')
Both of them give me the following errors:
AttributeError: 'str' object has no attribute 'write'