add option to use distinct and join in fetch instead of groupByKey