Reputation: 65
I have a file that have this type of schema :
and trying to create a table or dataframe base on them. Before that, have managed to upload the file using this script :
first_row_is_header = "true"
infer_schema = "true"
delimiter = ":"
df4 = spark.read.option("multiLine","true") \
.option("inferSchema", infer_schema) \
.option("sep", delimiter) \
.json ("/FileStore/tables/Ca_sect2.json")
End result become like this :
How do I convert the result below into table form? Have tried several types of scripts like dataFrame.createOrReplaceTempView
, but keep on failing to get the result.
Grateful for some help, as have been trying for 2 days.
Thank you very much.
Upvotes: 0
Views: 797
Reputation: 32720
What you want is to explode the array structure of developerSales
:
df.withColumn("sales", explode(col("developerSales")))\
.select(col("developer"), col("sales.*"))\
.show()
Upvotes: 1