def collapse_group_expr(groupx, cols, ret_row):
    """collapses columns matching the group expression. I'm sure this is buggy; look at a real DB's imp of this."""
    for i, col in enumerate(cols.children):
        if col == groupx:
            ret_row[i] = ret_row[i][0]
    return ret_row
