diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt index cd7276e69..1f521181c 100644 --- a/src/iceberg/CMakeLists.txt +++ b/src/iceberg/CMakeLists.txt @@ -20,6 +20,7 @@ set(ICEBERG_INCLUDES "$" set(ICEBERG_SOURCES arrow_c_data_internal.cc demo.cc + expression/expression.cc json_internal.cc partition_field.cc partition_spec.cc @@ -35,7 +36,6 @@ set(ICEBERG_SOURCES transform_function.cc type.cc snapshot.cc - expression.cc util/murmurhash3_internal.cc) set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS) @@ -68,6 +68,7 @@ add_iceberg_lib(iceberg iceberg_install_all_headers(iceberg) +add_subdirectory(expression) add_subdirectory(util) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_export.h diff --git a/src/iceberg/expression/CMakeLists.txt b/src/iceberg/expression/CMakeLists.txt new file mode 100644 index 000000000..b06b1d7b0 --- /dev/null +++ b/src/iceberg/expression/CMakeLists.txt @@ -0,0 +1,18 @@ +# 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. + +iceberg_install_all_headers(iceberg/expression) diff --git a/src/iceberg/expression.cc b/src/iceberg/expression/expression.cc similarity index 93% rename from src/iceberg/expression.cc rename to src/iceberg/expression/expression.cc index d53cef3cc..2914c81f4 100644 --- a/src/iceberg/expression.cc +++ b/src/iceberg/expression/expression.cc @@ -17,10 +17,12 @@ * under the License. */ -#include "expression.h" +#include "iceberg/expression/expression.h" #include +#include "iceberg/result.h" + namespace iceberg { // True implementation @@ -49,8 +51,7 @@ std::string And::ToString() const { Result> And::Negate() const { // TODO(yingcai-cy): Implement Or expression - return unexpected( - Error(ErrorKind::kInvalidExpression, "And negation not yet implemented")); + return InvalidExpressionError("And negation not yet implemented"); } bool And::Equals(const Expression& expr) const { diff --git a/src/iceberg/expression.h b/src/iceberg/expression/expression.h similarity index 100% rename from src/iceberg/expression.h rename to src/iceberg/expression/expression.h diff --git a/src/iceberg/result.h b/src/iceberg/result.h index 06c78747e..f8b3740b6 100644 --- a/src/iceberg/result.h +++ b/src/iceberg/result.h @@ -78,4 +78,12 @@ auto JsonParseError(const std::format_string fmt, Args&&... args) .message = std::format(fmt, std::forward(args)...)}); } +/// \brief Create an unexpected error with kInvalidExpression +template +auto InvalidExpressionError(const std::format_string fmt, Args&&... args) + -> unexpected { + return unexpected({.kind = ErrorKind::kInvalidExpression, + .message = std::format(fmt, std::forward(args)...)}); +} + } // namespace iceberg diff --git a/test/expression_test.cc b/test/expression_test.cc index 1ca50cb5f..f722d62c5 100644 --- a/test/expression_test.cc +++ b/test/expression_test.cc @@ -17,7 +17,7 @@ * under the License. */ -#include "iceberg/expression.h" +#include "iceberg/expression/expression.h" #include