class GroupByConsumer {

    public static boolean groupedByClusteredColumnOrPrimaryKeys(DocTableInfo tableInfo,
                                                                WhereClause whereClause,
                                                                List<Symbol> groupBySymbols) {
        if (groupBySymbols.size() > 1) {
            return groupedByPrimaryKeys(tableInfo.primaryKey(), groupBySymbols);
        }

        /**
         * if the table has more than one partition there are multiple shards which might even be on different nodes
         * so one shard doesn't contain all "clustered by" values
         * -> need to use a distributed group by.
         */
        if (tableInfo.isPartitioned() && whereClause.partitions().size() != 1) {
            return false;
        }

        // this also handles the case if there is only one primary key.
        // as clustered by column == pk column  in that case
        Symbol groupByKey = groupBySymbols.get(0);
        return groupByKey instanceof Reference ref && ref.column().equals(tableInfo.clusteredBy());
    }

    private static boolean groupedByPrimaryKeys(List<ColumnIdent> primaryKeys, List<Symbol> groupBy) {<FILL_FUNCTION_BODY>}
}

        if (groupBy.size() != primaryKeys.size()) {
            return false;
        }
        for (int i = 0, groupBySize = groupBy.size(); i < groupBySize; i++) {
            Symbol groupBySymbol = groupBy.get(i);
            if (groupBySymbol instanceof Reference ref) {
                ColumnIdent columnIdent = ref.column();
                ColumnIdent pkIdent = primaryKeys.get(i);
                if (!pkIdent.equals(columnIdent)) {
                    return false;
                }
            } else {
                return false;
            }
        }
        return true;
    
<no_super_class>