Skip to content

Commit 06ce20f

Browse files
authored
refactor: add expression subdirectory (#81)
1 parent 9c74fd2 commit 06ce20f

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

src/iceberg/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(ICEBERG_INCLUDES "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>"
2020
set(ICEBERG_SOURCES
2121
arrow_c_data_internal.cc
2222
demo.cc
23+
expression/expression.cc
2324
json_internal.cc
2425
partition_field.cc
2526
partition_spec.cc
@@ -35,7 +36,6 @@ set(ICEBERG_SOURCES
3536
transform_function.cc
3637
type.cc
3738
snapshot.cc
38-
expression.cc
3939
util/murmurhash3_internal.cc)
4040

4141
set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS)
@@ -68,6 +68,7 @@ add_iceberg_lib(iceberg
6868

6969
iceberg_install_all_headers(iceberg)
7070

71+
add_subdirectory(expression)
7172
add_subdirectory(util)
7273

7374
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/iceberg_export.h
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
iceberg_install_all_headers(iceberg/expression)

src/iceberg/expression.cc renamed to src/iceberg/expression/expression.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
* under the License.
1818
*/
1919

20-
#include "expression.h"
20+
#include "iceberg/expression/expression.h"
2121

2222
#include <format>
2323

24+
#include "iceberg/result.h"
25+
2426
namespace iceberg {
2527

2628
// True implementation
@@ -49,8 +51,7 @@ std::string And::ToString() const {
4951

5052
Result<std::shared_ptr<Expression>> And::Negate() const {
5153
// TODO(yingcai-cy): Implement Or expression
52-
return unexpected(
53-
Error(ErrorKind::kInvalidExpression, "And negation not yet implemented"));
54+
return InvalidExpressionError("And negation not yet implemented");
5455
}
5556

5657
bool And::Equals(const Expression& expr) const {
File renamed without changes.

src/iceberg/result.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,12 @@ auto JsonParseError(const std::format_string<Args...> fmt, Args&&... args)
7878
.message = std::format(fmt, std::forward<Args>(args)...)});
7979
}
8080

81+
/// \brief Create an unexpected error with kInvalidExpression
82+
template <typename... Args>
83+
auto InvalidExpressionError(const std::format_string<Args...> fmt, Args&&... args)
84+
-> unexpected<Error> {
85+
return unexpected<Error>({.kind = ErrorKind::kInvalidExpression,
86+
.message = std::format(fmt, std::forward<Args>(args)...)});
87+
}
88+
8189
} // namespace iceberg

test/expression_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
#include "iceberg/expression.h"
20+
#include "iceberg/expression/expression.h"
2121

2222
#include <memory>
2323

0 commit comments

Comments
 (0)