This is my schema
my_schema = StructType([
StructField('uid', StringType(), True),
StructField('test_id', StringType(), True),
StructField("struct_ids", ArrayType(
StructType([
StructField("st", IntegerType(), True),
StructField("mt", IntegerType(), True),
])
) )
])
this is my data
my_data = {'table_test': {'uid': 'test',
'test_id': 'test',
'struct_ids': [{'st': 1234, 'mt': 1111}, {'st': 6789, 'mt': 2222}]}}
This is how I create a dataframe and it works.
df = spark.createDataFrame(data=[my_data['table_test']], schema=my_schema)
How to create multiple rows? eg: Add this row to the table during creation of table or later.
{'uid': 'test2',
'test_id': 'test2',
'struct_ids': [{'st': 3333, 'mt': 114411}, {'st': 333, 'mt': 444}]}
Creating an array did not work.