Conversation
602bef1 to
684d85c
Compare
src/iceberg/expression/json_serde.cc
Outdated
|
|
||
| Result<std::shared_ptr<NamedReference>> NamedReferenceFromJson( | ||
| const nlohmann::json& json) { | ||
| if (!json.is_string()) { |
src/iceberg/expression/json_serde.cc
Outdated
| * under the License. | ||
| */ | ||
|
|
||
| #include <cctype> |
src/iceberg/expression/json_serde.cc
Outdated
| 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.
| 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.
windows does not seem to like it when we don't do the explicit copy.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
What is the error message in the failed windows ci? Can we figure it out how to fix this since other places are good with it?
684d85c to
8093c92
Compare
src/iceberg/expression/json_serde.cc
Outdated
|
|
||
| Result<std::shared_ptr<UnboundTransform>> UnboundTransformFromJson( | ||
| const nlohmann::json& json) { | ||
| if (json.is_object() && json.contains(kType) && json[kType] == kTransform && |
There was a problem hiding this comment.
From the build error msg, it seems windows don't like json[kType] == kTransform, you might change this back.
src/iceberg/expression/json_serde.cc
Outdated
| nlohmann::json json; | ||
| json[kType] = kTransform; | ||
| json[kTransform] = transform.transform()->ToString(); | ||
| json[kTerm] = std::string(mutable_transform.reference()->name()); |
There was a problem hiding this comment.
| json[kTerm] = std::string(mutable_transform.reference()->name()); | |
| json[kTerm] = mutable_transform.reference()->name(); |
line 146 seems ok, so the same apply to line 148?
There was a problem hiding this comment.
I donl think like 146 is ok, after some research, I think what is happening here is the following: MSVC is having hard times deciding what overload for operators to use between
nlohmann::json::operator== (from nlohmann_json library)
std::operator==<char, std::char_traits> for string_view (from MSVC's STL)
a similar confusion is happening for constructors. I can push a another diff to confirm, I will push another version to confirm
There was a problem hiding this comment.
Good to know. It seems that Compiler Explorer doesn't currently support libraries with MSVC[1], so we have to rely on the CI to confirm that.
6e6031b to
f7a9960
Compare
src/iceberg/type_fwd.h
Outdated
| class Literal; | ||
| class Term; | ||
| class UnboundPredicate; | ||
| class NamedReference; |
| EXPECT_FALSE(IsUnaryOperation(Expression::Operation::kTrue)); | ||
| } | ||
|
|
||
| TEST(ExpressionJsonTest, NameReferenceRoundTrip) { |
There was a problem hiding this comment.
Can we try to reuse TestJsonConversion to avoid boilerplate of round trip test like this?
iceberg-cpp/src/iceberg/test/json_serde_test.cc
Lines 76 to 84 in b15ac65
src/iceberg/expression/json_serde.cc
Outdated
| 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.
What is the error message in the failed windows ci? Can we figure it out how to fix this since other places are good with it?
src/iceberg/expression/json_serde.cc
Outdated
| ICEBERG_ASSIGN_OR_RAISE(auto ref, NamedReference::Make(json.get<std::string>())); | ||
| return std::shared_ptr<NamedReference>(std::move(ref)); |
There was a problem hiding this comment.
| ICEBERG_ASSIGN_OR_RAISE(auto ref, NamedReference::Make(json.get<std::string>())); | |
| return std::shared_ptr<NamedReference>(std::move(ref)); | |
| return NamedReference::Make(json.get<std::string>()); |
src/iceberg/expression/json_serde.cc
Outdated
| return json; | ||
| } | ||
|
|
||
| Result<std::shared_ptr<UnboundTransform>> UnboundTransformFromJson( |
There was a problem hiding this comment.
Could you please call this in the ExpressionFromJson in this PR and verify it works in the test case? It is still unclear to me whether the checks below is worth because we should already know that json is an unbound transform and those checks are performed in the ExpressionFromJson already.
a5acbaa to
bb5cca5
Compare
bb5cca5 to
78d3930
Compare
This is the second PR in addressing serde for expression for predicate push down. It implements the rest of the expression serde logic. It closely matches the java Implementation at https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/expressions/ExpressionParser.java
I tried to achieve/improve on the java integration test coverage.
One gap that is not addressed in this task is that during binding, even if type information is available, a bunch of complex literals are serialized as strings but no string to specific type exist yet. I will work on that next.