0

I have a file that have this type of schema :

enter image description here

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 :

enter image description here

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.

1 Answer 1

1

What you want is to explode the array structure of developerSales:

df.withColumn("sales", explode(col("developerSales")))\
  .select(col("developer"), col("sales.*"))\
  .show()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.