Added groupingsets and conditional in agg_retrieve_direct