Skip to content

test: run the partition-transforms surface of iceberg-verification - #1173

Open
WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:feat/iceberg-verification-phase2
Open

WZhuo wants to merge 1 commit into
apache:mainfrom
WZhuo:feat/iceberg-verification-phase2

Conversation

@WZhuo

@WZhuo WZhuo commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Phase 2 of #909: run the partition-transforms surface of apache/iceberg-verification in verification_test, covering all eight subdirectories: identity, bucket, truncate, year, month, day, hour and void.

For each case the test:

  1. Parses input.source_type with TypeFromJson and input.transform with TransformFromString, then binds the transform with Transform::Bind.
  2. Checks that the bound result type is one of decoded.result_types. The expected type strings are parsed and compared as types, so the check does not depend on how ToJson spells a type.
  3. Decodes each of input.values under the source type, applies the bound transform, and compares the result with the value at the same index of decoded.values. Expected values are decoded under the result type and compared as literals, so offset-equivalent timestamptz strings and scale-preserving decimals compare by value.

Values are decoded with LiteralFromJson. The one exception is long, which this surface writes as a decimal string so JSON number handling cannot lose 64-bit precision. Failures are labeled <subdir>/<case-id> result_type or <subdir>/<case-id> values[<index>], as the surface README requires.

All 75 cases are run. 73 pass and 2 fail:

Case Failure
identity/identity-float values[2]: cannot decode input 0: Cannot parse 0 as a float value
identity/identity-double values[2]: cannot decode input 0: Cannot parse 0 as a double value

LiteralFromJson mirrors Java's SingleValueParser.fromJson and requires a JSON number with a fractional part or exponent for float and double. Appendix D of the spec only says "JSON number", and the fixture writes 0. Java on main rejects the same value. I'll raise this on dev@ to decide whether readers should accept any JSON number, so the test reports these cases instead of working around them.

Validation: built and ran verification_test locally on macOS with the results above.

Add the partition-transforms surface to verification_test, covering all
eight subdirectories: identity, bucket, truncate, year, month, day, hour
and void.

Each case binds `input.transform` to `input.source_type` through
TransformFromString and Transform::Bind, checks that the result type is
one of `decoded.result_types`, and applies the bound transform to each
input value. Values are decoded from the surface's language-neutral form
through LiteralFromJson, except that long values are decimal strings in
this surface. Expected values are decoded under the result type and
compared as literals, so offset-equivalent timestamptz strings and
scale-preserving decimals compare by value. Failures are labeled
`result_type` or `values[<index>]` as the surface README requires.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall, just two comments on float/double json decoding and checking literal types/scales.

StringUtils::ParseNumber<int64_t>(json.get<std::string>()));
return Literal::Long(value);
}
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to my understanding, LiteralFromJson requires a floating-point json number (is_number_float()), so 0 in identity-float and identity-double fails decoding before the transform even runs. should we accept is_number() for float/double in DecodeValue (or document those two cases if the failures are intentional)?

+    case TypeId::kFloat:
+      if (!json.is_number()) {
+        return JsonParseError("float value {} is not a number", json.dump());
+      }
+      return Literal::Float(json.get<float>());
+    case TypeId::kDouble:
+      if (!json.is_number()) {
+        return JsonParseError("double value {} is not a number", json.dump());
+      }
+      return Literal::Double(json.get<double>());
     default:
       return LiteralFromJson(json, type.get());

expected.error().message));
continue;
}
if (actual->IsNull() || *actual != *expected) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*actual != *expected only checks value equality, so a decimal with the wrong scale or an int matching a date day ordinal would still pass. could we also check the actual literal's type and decimal scale here (normalizing day int results to Literal::Date)?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants