I am dealing with with DynamoDB JSON that is similar to this:
{
"name" : {"S" : "John"},
"birthday": {
"M" : {
"month" : {"N": 1},
"year" : {"N": 2000},
"day" : {"N": 2}
}
}
}
When I read this in spark
val df = spark.read.json("s3://path")
I get a complicated schema:
name : structType ( S : String),
birthday: structType (
M : StructType (
month : structType (N : int),
year : structType (N : int),
day : structType (N : int),
)
)
Instead, I want to change the schema to something like
name : String
birthday : structType (
month : int
year : int
day : int
)
Is there a way to do this?
My schema is in fact much larger than this example, with many deeply nested structs. I wonder also if there is dynamic way of "normalizing" the schema.