zhjwpku commented on code in PR #401: URL: https://github.com/apache/iceberg-cpp/pull/401#discussion_r2621279133
########## src/iceberg/update/update_partition_spec.h: ########## @@ -0,0 +1,241 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#pragma once + +/// \file iceberg/update/update_partition_spec.h +/// API for partition spec evolution. + +#include <memory> +#include <optional> +#include <string> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +#include "iceberg/iceberg_export.h" +#include "iceberg/pending_update.h" +#include "iceberg/result.h" +#include "iceberg/table_identifier.h" +#include "iceberg/type_fwd.h" + +namespace iceberg { + +/// \brief API for partition spec evolution. +/// +/// When committing, these changes will be applied to the current table metadata. +/// Commit conflicts will not be resolved and will result in a CommitFailed error. +class ICEBERG_EXPORT UpdatePartitionSpec : public PendingUpdate { + public: + /// \brief Construct an UpdatePartitionSpec for the specified table. + /// + /// \param identifier The table identifier. + /// \param catalog The catalog. + /// \param base The base table metadata. + UpdatePartitionSpec(TableIdentifier identifier, std::shared_ptr<Catalog> catalog, + std::shared_ptr<TableMetadata> base); + + ~UpdatePartitionSpec() override; + + /// \brief Set whether column resolution in the source schema should be case sensitive. + UpdatePartitionSpec& CaseSensitive(bool is_case_sensitive); + + /// \brief Add a new partition field from a source column. + /// + /// The partition field will be created as an identity partition field for the given + /// source column, with the same name as the source column. + /// + /// \param source_name Source column name in the table schema. + /// \return Reference to this for method chaining. + UpdatePartitionSpec& AddField(const std::string& source_name); + + /// \brief Add a new partition field from an unbound term. + /// + /// The partition field will use the term's transform or the identity transform if + /// the term is a reference. + /// + /// \param term The unbound term representing the partition transform. + /// \return Reference to this for method chaining. + UpdatePartitionSpec& AddField(std::shared_ptr<UnboundTerm<BoundReference>> term); + + /// \brief Add a new partition field from an unbound transform term. + /// + /// \param term The unbound transform term. + /// \return Reference to this for method chaining. + UpdatePartitionSpec& AddField(std::shared_ptr<UnboundTerm<BoundTransform>> term); + + /// \brief Add a new partition field with a custom name. + /// + /// \param name Name for the partition field. + /// \param term The unbound term representing the partition transform. + /// \return Reference to this for method chaining. + UpdatePartitionSpec& AddField(std::optional<std::string> name, Review Comment: Done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
