I have a JSON like this:
{
"uin":10000,
"role":[
{"role_id":1, "role_level": 10},
{"role_id":2, "role_level": 1}
]
}
{ "uin":10001,
"role":[
{"role_id":1, "role_level": 1},
{"role_id":2, "role_level": 1},
{"role_id":3, "role_level": 1},
{"role_id":4, "role_level": 20}
]
}
I want to query a uin which has more than two roles. How can I do it using Spark SQL?
You can use DataFrame and UserDefinedFunction to achieve what you want, as shown below. I've tried in spark-shell.