-
Notifications
You must be signed in to change notification settings - Fork 86
feat: add json serde for expressions #553
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
602bef1 to
684d85c
Compare
|
|
||
| Result<std::shared_ptr<NamedReference>> NamedReferenceFromJson( | ||
| const nlohmann::json& json) { | ||
| if (!json.is_string()) { |
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.
add a [[unlikely]] hint?
| * under the License. | ||
| */ | ||
|
|
||
| #include <cctype> |
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.
do we need this header?
| nlohmann::json ToJson(const UnboundTransform& transform) { | ||
| auto& mutable_transform = const_cast<UnboundTransform&>(transform); | ||
| nlohmann::json json; | ||
| json[kType] = std::string(kTransform); |
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.
| json[kType] = std::string(kTransform); | |
| json[kType] = kTransform; |
I don't think the string ctor around kTransform is necessary. The same applies to other places as well.
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.
windows does not seem to like it when we don't do the explicit copy.
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.
Oh, I'm not entirely sure, but I noticed a similar usage here: https://github.com/apache/iceberg-cpp/blob/main/src/iceberg/json_serde.cc#L1295
This is the second PR in addressing serde for expression for predicate push down. It focuses on unbound transforms and and named references.
Added unit tests to ensure that serialization happens correctly. while name references will map just names like schema columns, unbound transforms will make sure take care of transform serde. for example it will ensure
{ "type": "transform", "transform": "bucket[16]", "term": "id" }is converted to an object and vice versa.