protected function filterInCondition(array $data, $operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }

        list($column, $values) = $operands;

        if ($values === [] || $column === []) {
            return $operator === 'IN' ? [] : $data;
        }

        $values = (array) $values;

        if (count($column) > 1) {
            throw new InvalidParamException("Operator '$operator' allows only a single column.");
        }

        if (is_array($column)) {
            $column = reset($column);
        }

        foreach ($values as $i => $value) {
            if (is_array($value)) {
                $values[$i] = isset($value[$column]) ? $value[$column] : null;
            }
        }

        if (strncmp('NOT', $operator, 3) === 0) {
            return array_filter($data, function ($row) use ($column, $values) {
                return !in_array($row[$column], $values);
            });
        }

        return array_filter($data, function ($row) use ($column, $values) {
            return in_array($row[$column], $values);
        });
    }