Repository navigation
Conversation
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
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
*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)?
Phase 2 of #909: run the
partition-transformssurface of apache/iceberg-verification inverification_test, covering all eight subdirectories:identity,bucket,truncate,year,month,day,hourandvoid.For each case the test:
input.source_typewithTypeFromJsonandinput.transformwithTransformFromString, then binds the transform withTransform::Bind.decoded.result_types. The expected type strings are parsed and compared as types, so the check does not depend on howToJsonspells a type.input.valuesunder the source type, applies the bound transform, and compares the result with the value at the same index ofdecoded.values. Expected values are decoded under the result type and compared as literals, so offset-equivalenttimestamptzstrings and scale-preserving decimals compare by value.Values are decoded with
LiteralFromJson. The one exception islong, which this surface writes as a decimal string so JSON number handling cannot lose 64-bit precision. Failures are labeled<subdir>/<case-id> result_typeor<subdir>/<case-id> values[<index>], as the surface README requires.All 75 cases are run. 73 pass and 2 fail:
identity/identity-floatvalues[2]: cannot decode input 0: Cannot parse 0 as a float valueidentity/identity-doublevalues[2]: cannot decode input 0: Cannot parse 0 as a double valueLiteralFromJsonmirrors Java'sSingleValueParser.fromJsonand requires a JSON number with a fractional part or exponent forfloatanddouble. Appendix D of the spec only says "JSON number", and the fixture writes0. 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_testlocally on macOS with the results above.