Use GROUP BY instead of DISTINCT ON if arguments are provided.
435497
function (args) {
            args = argsToArray(arguments);
            return !args.length ? this._super(arguments) : this.group.apply(this, args);
        }
984599
def make_argument_subquery(arg):
        
        return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg
1073180
def uniq_by_id(self, records):
        """"""
        uniq = []
        keys = set()
        for rec in records:
            rec_id = rec[self._id_field]
            if rec_id not in keys:
                uniq.append(rec)
                keys.add(rec_id)
        return uniq
544054
def group_by(iterable, key_func):
    """"""
    groups = (
        list(sub) for key, sub in groupby(iterable, key_func)
    )
    return zip(groups, groups)
202571
public SqlBuilder groupBy(final String what) {
    if (Strings.isNotEmpty(what)) groups.add(what);
    return this;
  }
236429
def group_records_by_type(records):
    """"""
    update_records, delete_records = [], []
    for r in records:
        if isinstance(r, str):
            break

        if r['detail']['eventName'] in UPDATE_EVENTS:
            update_records.append(r)
        else:
            delete_records.append(r)
    return update_records, delete_records
1220404
protected void appendGroupByClause(List groupByFields, StringBuffer buf)
    {
        if (groupByFields == null || groupByFields.size() == 0)
        {
            return;
        }

        buf.append(" GROUP BY ");
        for (int i = 0; i < groupByFields.size(); i++)
        {
            FieldHelper cf = (FieldHelper) groupByFields.get(i);
 
            if (i > 0)
            {
                buf.append(",");
            }

            appendColName(cf.name, false, null, buf);
        }
    }
1170979
public Query groupby(final Expression... groupbyColumns) {
        if (groupbyColumns == null) {
            return this;
        }

        return groupby(Arrays.asList(groupbyColumns));
    }
1010187
def is_field_unique_by_group(df, field_col, group_col):
    ''' 
    '''
    def num_unique(x):
        return len(pd.unique(x))
    num_distinct = df.groupby(group_col)[field_col].agg(num_unique)
    return all(num_distinct == 1)
412158
def select_distinct(distinct_field=None, **kwargs):
    
    results = search_associations(rows=0,
                                  select_fields=[],
                                  facet_field_limits = {
                                      distinct_field : -1
                                  },
                                  facet_fields=[distinct_field],
                                  **kwargs
    )
    # TODO: map field
    return list(results['facet_counts'][distinct_field].keys())
1339670
def group_values(self, group_name):
        """"""
        group_index = self.groups.index(group_name)
        values = []
        for key in self.data_keys:
            if key[group_index] not in values:
                values.append(key[group_index])
        return values
1152513
static boolean isGroupByColumn(QuerySpecification select, int index) {
        if (!select.isGrouped) {
            return false;
        }
        for (int ii = 0; ii < select.groupIndex.getColumnCount(); ii++) {
            if (index == select.groupIndex.getColumns()[ii]) {
                return true;
            }
        }
        return false;
    }
1350670
function groupBy(item) {
    if (item instanceof Raw) {
      return this.groupByRaw.apply(this, arguments);
    }
    this._statements.push({
      grouping: 'group',
      type: 'groupByBasic',
      value: normalizeArr.apply(null, arguments)
    });
    return this;
  }
1165555
def groupBy(self, val):
        

        def by(result, key, value):
            if key not in result:
                result[key] = []
            result[key].append(value)

        res = self._group(self.obj, val, by)

        return self._wrap(res)
1206991
def get_duplicate_vals(self, table, column):
        """"""
        query = 'SELECT {0} FROM {1} GROUP BY {0} HAVING COUNT(*) > 1'.format(join_cols(column), wrap(table))
        return self.fetch(query)
732093
def distinct(self, field=None):
        
        if field is None:
            self.funcs.append(('distinct', (), {}))
        else:
            self.distinct_field = field
        return self
1068654
public function groupBy()
    {
        $args = func_get_args();
        while ($arg = array_shift($args)) {
            $this->group->add($arg);
        }
        return $this;
    }