-
Notifications
You must be signed in to change notification settings - Fork 84
[Expr Serde] [PR 1/X] basic plumbing for serde support for expressions #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/result.h" | ||
|
|
||
| /// \file iceberg/expression/json_internal.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the comment in sync
| expression/expression.cc | ||
| expression/expressions.cc | ||
| expression/inclusive_metrics_evaluator.cc | ||
| expression/json_serde.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to update meson.build for any new file.
| ICEBERG_EXPORT nlohmann::json ToJson(const Model& model); | ||
|
|
||
| /// \note Don't forget to add `ICEBERG_DEFINE_FROM_JSON` to the end of | ||
| /// `json_internal.cc` to define the `FromJson` function for the model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| add_iceberg_test(expression_test | ||
| SOURCES | ||
| aggregate_test.cc | ||
| expression_json_test.cc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment for meson.build
src/iceberg/expression/json_serde.cc
Outdated
| Result<std::shared_ptr<Expression>> ExpressionFromJson(const nlohmann::json& json) { | ||
| // Handle boolean | ||
| if (json.is_boolean()) { | ||
| return json.get<bool>() ? std::static_pointer_cast<Expression>(True::Instance()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use checked_pointer_cast
| EXPECT_EQ(result.value()->op(), Expression::Operation::kTrue); | ||
| } | ||
|
|
||
| TEST_F(ExpressionJsonTest, FalseExpression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two cases share a lot of similarities. Can we use a single test?
Summary
This is the first PR aimed a addressing #331
Because doing it in one go will be more error prone and will make review harder, I am splitting the change across several PR.
This first one covers:
Test
~/Documents/my_iceberg/iceberg-cpp bool_expressio_serde ./build/src/iceberg/test/expression_test --gtest_filter="ExpressionJson*" ✔ 1297 13:53:47
Running main() from gmock_main.cc
Note: Google Test filter = ExpressionJson*
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from ExpressionJsonTest
[ RUN ] ExpressionJsonTest.TrueExpression
[ OK ] ExpressionJsonTest.TrueExpression (0 ms)
[ RUN ] ExpressionJsonTest.FalseExpression
[ OK ] ExpressionJsonTest.FalseExpression (0 ms)
[----------] 2 tests from ExpressionJsonTest (0 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 2 tests.
idjiofack@Innocents-MacBook-Pro-2 ~/Documents/my_iceberg/iceberg-cpp bool_expressio_serde