public function add($name, $type)
    {
        $invalidIntTypes = [
            Database::TYPE_STRUCT,
            Database::TYPE_ARRAY
        ];

        if (is_int($type) && in_array($type, $invalidIntTypes)) {
            throw new \InvalidArgumentException(
                '`Database::TYPE_ARRAY` and `Database::TYPE_STRUCT` are not valid as struct types. ' .
                'Instead provide `Google\Cloud\Spanner\ArrayType` or `Google\Cloud\Spanner\StructType`.'
            );
        }

        $child = null;
        if ($type instanceof StructType) {
            $child = $type;
            $type = Database::TYPE_STRUCT;
        } elseif ($type instanceof ArrayType) {
            $child = $type;
            $type = Database::TYPE_ARRAY;
        }

        if (!in_array($type, ValueMapper::$allowedTypes)) {
            throw new \InvalidArgumentException(sprintf(
                'Field type `%s` is not valid.',
                $type
            ));
        }

        $this->fields[] = [
            'name' => $name,
            'type' => $type,
            'child' => $child
        ];

        return $this;
    }