Conditional Sub query in N1QL

What is the best approach if i want to get some data via sub query based on the first part of my key ?
my DocKey looks like this either contact::guid , or farm:::guid or lead::guid and so on. I have tasks
which can be either assigned to any of the above groups and when i get all tasks for a user i get it via the following subquery.

(SELECT * FROM Contacts USE KEYS c.parent_id) as parent

instead of getting all back i want something like

if c.parent_id contains "contact"
(SELECT "contact" as type, fname, lname FROM Contacts USE KEYS c.parent_id) as parent`
if c.parent_id contains "lead"
(SELECT  "lead" as type, fname, lname FROM Contacts USE KEYS c.parent_id) as parent`
if c.parent_id contains "farm"
(SELECT  "farm" as type, owner_fname, owner_lname FROM Contacts USE KEYS c.parent_id) as parent`

what is the best and most flexible approach for this

There is no if in the n1ql you can also use CASE

(SELECT SPLIT(c.parent_id,"::")[0] as type, fname, lname FROM Contacts USE KEYS c.parent_id