Skip to content

Commit 6fe4640

Browse files
committed
revert: leave expression/json_serde.cc untouched (out of PR scope)
Revert the float/double LiteralFromJson leniency change and its test: that is the pre-existing shared literal parser, not code this PR introduces. The integer-encoded float-default interop gap (Java writes float defaults as bare ints) is a separate follow-up in a PR that owns the expression serde.
1 parent 38bbdb0 commit 6fe4640

2 files changed

Lines changed: 2 additions & 15 deletions

File tree

src/iceberg/expression/json_serde.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,13 @@ Result<Literal> LiteralFromJson(const nlohmann::json& json, const Type* type) {
342342
return Literal::Long(json.get<int64_t>());
343343

344344
case TypeId::kFloat:
345-
// Accept an integer JSON token too (e.g. `1`), matching Java's lenient numeric
346-
// parsing; otherwise a float default written as a bare integer fails to read.
347-
if (!json.is_number()) [[unlikely]] {
345+
if (!json.is_number_float()) [[unlikely]] {
348346
return JsonParseError("Cannot parse {} as a float value", SafeDumpJson(json));
349347
}
350348
return Literal::Float(json.get<float>());
351349

352350
case TypeId::kDouble:
353-
if (!json.is_number()) [[unlikely]] {
351+
if (!json.is_number_float()) [[unlikely]] {
354352
return JsonParseError("Cannot parse {} as a double value", SafeDumpJson(json));
355353
}
356354
return Literal::Double(json.get<double>());

src/iceberg/test/schema_json_test.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,6 @@ TEST(SchemaJsonTest, CrossTypeDefaultNormalizedRoundTrip) {
258258
EXPECT_EQ(original, *reparsed);
259259
}
260260

261-
TEST(SchemaJsonTest, FloatDefaultAcceptsIntegerEncoding) {
262-
// Java writes a float/double default as a bare integer token (e.g. 1, not 1.0); it must
263-
// parse, matching Java's lenient numeric reading.
264-
constexpr std::string_view json =
265-
R"({"fields":[{"id":1,"initial-default":1,"name":"f","required":true,"type":"float"}],"schema-id":1,"type":"struct"})";
266-
ICEBERG_UNWRAP_OR_FAIL(auto schema, SchemaFromJson(nlohmann::json::parse(json)));
267-
const auto& field = schema->fields()[0];
268-
ASSERT_NE(field.initial_default(), nullptr);
269-
EXPECT_EQ(*field.initial_default(), Literal::Float(1.0F));
270-
}
271-
272261
TEST(SchemaJsonTest, UnknownFieldRoundTrip) {
273262
constexpr std::string_view json =
274263
R"({"fields":[{"id":1,"name":"mystery","required":false,"type":"unknown"}],"schema-id":1,"type":"struct"})";

0 commit comments

Comments
 (0)