wgtmac commented on code in PR #177: URL: https://github.com/apache/iceberg-cpp/pull/177#discussion_r2376060372
########## src/iceberg/expression/expressions.h: ########## @@ -0,0 +1,273 @@ +/* + * 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/expression/expressions.h +/// Factory methods for creating expressions. + +#include <initializer_list> +#include <memory> +#include <string> +#include <vector> + +#include "iceberg/expression/literal.h" +#include "iceberg/expression/predicate.h" +#include "iceberg/expression/term.h" +#include "iceberg/iceberg_export.h" + +namespace iceberg { + +/// \brief Factory methods for creating expressions. +class ICEBERG_EXPORT Expressions { + public: + // Logical operations + + /// \brief Create an AND expression. + static std::shared_ptr<Expression> And(std::shared_ptr<Expression> left, + std::shared_ptr<Expression> right); + + /// \brief Create an OR expression. + static std::shared_ptr<Expression> Or(std::shared_ptr<Expression> left, + std::shared_ptr<Expression> right); + + // Transform functions + + /// \brief Create a bucket transform term. + static std::shared_ptr<UnboundTransform> Bucket(std::string name, int32_t num_buckets); + + /// \brief Create a year transform term. + static std::shared_ptr<UnboundTransform> Year(std::string name); + + /// \brief Create a month transform term. + static std::shared_ptr<UnboundTransform> Month(std::string name); + + /// \brief Create a day transform term. + static std::shared_ptr<UnboundTransform> Day(std::string name); + + /// \brief Create an hour transform term. + static std::shared_ptr<UnboundTransform> Hour(std::string name); + + /// \brief Create a truncate transform term. + static std::shared_ptr<UnboundTransform> Truncate(std::string name, int32_t width); + + /// \brief Create a transform expression. + static std::shared_ptr<UnboundTransform> Transform( + std::string name, std::shared_ptr<Transform> transform); + + // Unary predicates + + /// \brief Create an IS NULL predicate for a field name. + static std::shared_ptr<UnboundPredicate<BoundReference>> IsNull(std::string name); + + /// \brief Create an IS NULL predicate for an unbound term. + template <typename B> + static std::shared_ptr<UnboundPredicate<B>> IsNull( + std::shared_ptr<UnboundTerm<B>> expr); + + /// \brief Create a NOT NULL predicate for a field name. + static std::shared_ptr<UnboundPredicate<BoundReference>> NotNull(std::string name); Review Comment: Right, so the return type is a `UnboundPredicate` whose bound type is a `BoundReference `. -- 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]
