Expression (meta(`instance`).`id`) must depend only on group keys or aggregates

Hi @vsr1 I have a small issue, below is the query which is working absolutely fine.

SELECT MIN([ instance.expiryTime, { instance, fragment }])[1].*
FROM preview AS instance
JOIN preview AS fragment ON (instance.fragmentId = fragment.[‘path’])
AND fragment.externalId IN [“ashish-123”,“ashish-456”]
AND (instance.effectiveTime <= 1613594291091
AND 1613594291091 <= instance.expiryTime)
GROUP BY fragment.externalId

but to include it in the spring boot project we have modified the query as

SELECT MIN([ instance.expiryTime, { instance, fragment }])[1].*,
META(instance).id AS _ID, META(instance).cas AS _CAS
FROM preview AS instance
JOIN preview AS fragment ON (instance.fragmentId = fragment.[‘path’])
AND fragment.externalId IN [“ashish-123”,“ashish-456”]
AND (instance.effectiveTime <= 1613594291091
AND 1613594291091 <= instance.expiryTime)
GROUP BY fragment.externalId

now with this the error message which I am getting is
“code”: 4210,
“msg”: “Expression (meta(instance).id) must depend only on group keys or aggregates.”,

Can you help me with this issue?

Thanks,

You can’t do that.

You can project as dummy constants
“xx” AS _ID, 0 AS _CAS

OR

MIN([ instance.expiryTime, { instance, fragment , "_ID": META(insatnce).id, "CAS":META(instance).cas }])[1].*

1 Like