This is an automated email from the ASF dual-hosted git repository.
laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-verification.git
The following commit(s) were added to refs/heads/main by this push:
new a078c0f Tooling: Recompute truncate and temporal partition transform
values (#25)
a078c0f is described below
commit a078c0f33d5beb828250c6b06ff6bab33eea7f55
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Fri Nov 27 23:48:23 2026 +0200
Tooling: Recompute truncate and temporal partition transform values (#25)
---
Makefile | 17 +++
dev/validate-fixtures.py | 171 +++++++++++++++++++----
table-spec/partition-transforms/README.md | 17 ++-
table-spec/partition-transforms/day/cases.json | 56 +++++++-
table-spec/partition-transforms/hour/cases.json | 16 ++-
table-spec/partition-transforms/month/cases.json | 29 +++-
table-spec/partition-transforms/year/cases.json | 29 +++-
7 files changed, 280 insertions(+), 55 deletions(-)
diff --git a/Makefile b/Makefile
index 7a83543..e21088a 100644
--- a/Makefile
+++ b/Makefile
@@ -126,6 +126,23 @@ selftest: $(VENV_STAMP) ## Check the validator accepts a
good fixture and reject
assert_partition_transform_reject "zero truncate width"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[0]","source_type":"int","values":[null,34]},"decoded":{"result_types":["int"],"values":[null,34]},"clause":"c","spec_ref":"s"}]}'
'cases/0/input/transform' truncate; \
assert_partition_transform_reject "zero bucket count outside bucket
directory"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"bucket[0]","source_type":"int","values":[null,34]},"decoded":{"result_types":["int"],"values":[null,0]},"clause":"c","spec_ref":"s"}]}'
'cases/0/input/transform'; \
assert_partition_transform_reject "bucket value checked outside bucket
directory"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"bucket[100]","source_type":"int","values":[null,34]},"decoded":{"result_types":["int"],"values":[null,78]},"clause":"c","spec_ref":"s"}]}'
'expected 79, found 78'; \
+ assert_partition_transform_accept "computed truncate value"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"int","values":[null,-1]},"decoded":{"result_types":["int"],"values":[null,-10]},"clause":"c","spec_ref":"s"}]}'
truncate; \
+ assert_partition_transform_accept "computed pre-epoch hour value"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"hour","source_type":"timestamp","values":[null,"1969-12-31T22:59:59.999999"]},"decoded":{"result_types":["int"],"values":[null,-2]},"clause":"c","spec_ref":"s"}]}'
hour; \
+ assert_partition_transform_reject "truncate int remainder toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"int","values":[null,-1]},"decoded":{"result_types":["int"],"values":[null,0]},"clause":"c","spec_ref":"s"}]}'
'expected -10, found 0' truncate; \
+ assert_partition_transform_reject "truncate long remainder toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"long","values":[null,"-1"]},"decoded":{"result_types":["long"],"values":[null,"0"]},"clause":"c","spec_ref":"s"}]}'
'expected "-10", found "0"' truncate; \
+ assert_partition_transform_reject "truncate decimal losing its scale"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"decimal(9,
2)","values":[null,"-0.05"]},"decoded":{"result_types":["decimal(9,
2)"],"values":[null,"-0.1"]},"clause":"c","spec_ref":"s"}]}' 'expected "-0.10",
found "-0.1"' truncate; \
+ assert_partition_transform_reject "truncate string counting UTF-8
bytes"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[3]","source_type":"string","values":[null,"a\ud83d\ude00bcd"]},"decoded":{"result_types":["string"],"values":[null,"a"]},"clause":"c","spec_ref":"s"}]}'
'cases/0/decoded/values/1' truncate; \
+ assert_partition_transform_reject "truncate binary longer than its
width"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[2]","source_type":"binary","values":[null,"000102"]},"decoded":{"result_types":["binary"],"values":[null,"000102"]},"clause":"c","spec_ref":"s"}]}'
'expected "0001", found "000102"' truncate; \
+ assert_partition_transform_reject "truncate decimal overflow"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"decimal(9,
2)","values":[null,"-9999999.99"]},"decoded":{"result_types":["decimal(9,
2)"],"values":[null,"-10000000.00"]},"clause":"c","spec_ref":"s"}]}' 'does not
settle decimal overflow' truncate; \
+ assert_partition_transform_reject "truncate with a trailing newline in
the transform"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]\n","source_type":"int","values":[null,1]},"decoded":{"result_types":["int"],"values":[null,null]},"clause":"c","spec_ref":"s"}]}'
'malformed transform' truncate; \
+ assert_partition_transform_reject "truncate int overflow"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[10]","source_type":"int","values":[null,-2147483648]},"decoded":{"result_types":["int"],"values":[null,-2147483650]},"clause":"c","spec_ref":"s"}]}'
'does not settle integer overflow' truncate; \
+ assert_partition_transform_reject "truncate string with a lone
surrogate"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"truncate[3]","source_type":"string","values":[null,"\ud83d"]},"decoded":{"result_types":["string"],"values":[null,"\ud83d"]},"clause":"c","spec_ref":"s"}]}'
'string must hold Unicode scalar values' truncate; \
+ assert_partition_transform_reject "pre-epoch year toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"year","source_type":"date","values":[null,"1968-12-31"]},"decoded":{"result_types":["int"],"values":[null,-1]},"clause":"c","spec_ref":"s"}]}'
'expected -2, found -1' year; \
+ assert_partition_transform_reject "pre-epoch month toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"month","source_type":"date","values":[null,"1968-12-31"]},"decoded":{"result_types":["int"],"values":[null,-12]},"clause":"c","spec_ref":"s"}]}'
'expected -13, found -12' month; \
+ assert_partition_transform_reject "pre-epoch day toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"day","source_type":"timestamp","values":[null,"1968-12-31T23:59:59.999999"]},"decoded":{"result_types":["date"],"values":[null,"1969-01-01"]},"clause":"c","spec_ref":"s"}]}'
'expected "1968-12-31", found "1969-01-01"' day; \
+ assert_partition_transform_reject "pre-epoch hour toward zero"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"hour","source_type":"timestamp_ns","values":[null,"1969-12-31T22:59:59.999999999"]},"decoded":{"result_types":["int"],"values":[null,-1]},"clause":"c","spec_ref":"s"}]}'
'expected -2, found -1' hour; \
+ assert_partition_transform_reject "timestamptz input without a zone"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"year","source_type":"timestamptz","values":[null,"1970-01-01T00:00:00"]},"decoded":{"result_types":["int"],"values":[null,0]},"clause":"c","spec_ref":"s"}]}'
'timestamp zone must match source type' year; \
+ assert_partition_transform_reject "temporal value checked outside its
directory"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"month","source_type":"date","values":[null,"1969-01-01"]},"decoded":{"result_types":["int"],"values":[null,-11]},"clause":"c","spec_ref":"s"}]}'
'expected -12, found -11'; \
assert_partition_transform_reject "fractional int bucket input"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"bucket[100]","source_type":"int","values":[null,34.5]},"decoded":{"result_types":["int"],"values":[null,79]},"clause":"c","spec_ref":"s"}]}'
'cases/0/input/values/1' bucket; \
assert_partition_transform_reject "boolean int bucket input"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"bucket[100]","source_type":"int","values":[null,true]},"decoded":{"result_types":["int"],"values":[null,79]},"clause":"c","spec_ref":"s"}]}'
'cases/0/input/values/1' bucket; \
assert_partition_transform_reject "number long bucket input"
'{"cases":[{"id":"a","valid":true,"input":{"transform":"bucket[100]","source_type":"long","values":[null,34]},"decoded":{"result_types":["int"],"values":[null,79]},"clause":"c","spec_ref":"s"}]}'
'cases/0/input/values/1' bucket; \
diff --git a/dev/validate-fixtures.py b/dev/validate-fixtures.py
index ebba01f..ef0c927 100755
--- a/dev/validate-fixtures.py
+++ b/dev/validate-fixtures.py
@@ -29,7 +29,7 @@ import re
import struct
import sys
import uuid
-from datetime import date, datetime, time, timezone
+from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
import jsonschema
@@ -133,7 +133,7 @@ def _json_scalar_equal(left, right):
return type(left) is type(right) and left == right
-def _partition_transform_errors(path, doc, check_bucket=True):
+def _partition_transform_errors(path, doc, check_values=True):
errors = []
cases = doc.get("cases") if isinstance(doc, dict) else None
if not isinstance(cases, list):
@@ -224,8 +224,8 @@ def _partition_transform_errors(path, doc,
check_bucket=True):
f"{sorted(required_result_types)}"
)
- if check_bucket and not errors:
- errors.extend(_bucket_errors(path, doc))
+ if check_values and not errors:
+ errors.extend(_computed_value_errors(path, doc))
return errors
@@ -265,7 +265,8 @@ def murmur3_x86_32(data):
return (h ^ (h >> 16)) & MASK
-def epoch_units(value, nanos=False):
+def epoch_nanos(value):
+ """Exact nanoseconds from the Unix epoch; a value without a zone is read
as UTC."""
match = TIMESTAMP.fullmatch(value)
if not match:
raise ValueError(f"invalid timestamp: {value}")
@@ -275,7 +276,11 @@ def epoch_units(value, nanos=False):
delta = instant - EPOCH
seconds = delta.days * 86400 + delta.seconds
digits = (fraction or "").ljust(9, "0")
- nanoseconds = seconds * 1_000_000_000 + int(digits or "0")
+ return seconds * 1_000_000_000 + int(digits or "0")
+
+
+def epoch_units(value, nanos=False):
+ nanoseconds = epoch_nanos(value)
if nanos and nanoseconds < 0 and nanoseconds % 1000:
raise ValueError("negative nanoseconds between microseconds need a
spec rounding rule")
return nanoseconds // 1000
@@ -293,6 +298,31 @@ def decimal_bytes(value):
return unscaled.to_bytes(length, "big", signed=True)
+def parse_decimal(source_type, value):
+ """Return (precision, scale, unscaled) for a scale-preserving decimal
string."""
+ precision, scale = map(
+ int, re.fullmatch(r"decimal\((\d+), (\d+)\)", source_type).groups()
+ )
+ decimal_pattern = (
+ r"-?(0|[1-9][0-9]*)"
+ + (r"\.[0-9]{" + str(scale) + r"}" if scale else "")
+ )
+ if not isinstance(value, str) or not re.fullmatch(decimal_pattern, value):
+ raise ValueError("decimal must be a scale-preserving string")
+ decimal = Decimal(value)
+ if len(decimal.as_tuple().digits) > precision:
+ raise ValueError(f"decimal must fit precision {precision} and scale
{scale}")
+ return precision, scale, int(value.replace(".", ""))
+
+
+def format_decimal(unscaled, scale):
+ sign = "-" if unscaled < 0 else ""
+ digits = str(abs(unscaled)).rjust(scale + 1, "0")
+ if not scale:
+ return sign + digits
+ return f"{sign}{digits[:-scale]}.{digits[-scale:]}"
+
+
def encode_for_hash(source_type, value):
if source_type == "int":
if type(value) is not int or not -(1 << 31) <= value < (1 << 31):
@@ -303,18 +333,7 @@ def encode_for_hash(source_type, value):
raise ValueError("long must be a decimal string")
return struct.pack("<q", int(value))
if source_type.startswith("decimal("):
- precision, scale = map(
- int, re.fullmatch(r"decimal\((\d+), (\d+)\)", source_type).groups()
- )
- decimal_pattern = (
- r"-?(0|[1-9][0-9]*)"
- + (r"\.[0-9]{" + str(scale) + r"}" if scale else "")
- )
- if not isinstance(value, str) or not re.fullmatch(decimal_pattern,
value):
- raise ValueError("decimal must be a scale-preserving string")
- decimal = Decimal(value)
- if len(decimal.as_tuple().digits) > precision:
- raise ValueError(f"decimal must fit precision {precision} and
scale {scale}")
+ parse_decimal(source_type, value)
return decimal_bytes(value)
if source_type == "date":
if not isinstance(value, str) or not
re.fullmatch(r"\d{4}-\d{2}-\d{2}", value):
@@ -360,7 +379,7 @@ def encode_for_hash(source_type, value):
raise ValueError(f"unsupported bucket source type: {source_type}")
-def _bucket_errors(path, doc):
+def check_appendix_b_vectors():
vectors = (
(struct.pack("<q", 34), 2017239379),
(struct.pack("<q", 17486), -653330422 & MASK),
@@ -370,28 +389,120 @@ def _bucket_errors(path, doc):
if murmur3_x86_32(data) != expected_hash:
raise AssertionError("Murmur3 does not reproduce an Appendix B
vector")
+
+def bucket_value(count, source_type, value):
+ return (murmur3_x86_32(encode_for_hash(source_type, value)) & 0x7FFFFFFF)
% count
+
+
+def truncate_value(width, source_type, value):
+ """Truncate Transform Details; remainders are positive, as Python's % is
for W > 0."""
+ if source_type in ("int", "long"):
+ if source_type == "int":
+ if type(value) is not int or not -(1 << 31) <= value < (1 << 31):
+ raise ValueError("int must be a 32-bit JSON integer")
+ number, bits = value, 32
+ else:
+ if not isinstance(value, str) or not
re.fullmatch(r"-?(0|[1-9][0-9]*)", value):
+ raise ValueError("long must be a decimal string")
+ number, bits = int(value), 64
+ if not -(1 << 63) <= number < (1 << 63):
+ raise ValueError("long must fit 64 bits")
+ truncated = number - number % width
+ if truncated < -(1 << (bits - 1)):
+ raise ValueError("the specification does not settle integer
overflow")
+ return truncated if source_type == "int" else str(truncated)
+ if source_type.startswith("decimal("):
+ precision, scale, unscaled = parse_decimal(source_type, value)
+ truncated = unscaled - unscaled % width
+ if len(str(abs(truncated))) > precision:
+ raise ValueError("the specification does not settle decimal
overflow")
+ return format_decimal(truncated, scale)
+ if source_type == "string":
+ if not isinstance(value, str):
+ raise ValueError("string must be a JSON string")
+ if any(0xD800 <= ord(char) <= 0xDFFF for char in value):
+ raise ValueError("string must hold Unicode scalar values")
+ return value[:width]
+ if source_type == "binary":
+ if not isinstance(value, str) or not re.fullmatch(r"(?:[0-9A-F]{2})*",
value):
+ raise ValueError("binary must be uppercase hexadecimal bytes")
+ return value[: 2 * width]
+ raise ValueError(f"unsupported truncate source type: {source_type}")
+
+
+def temporal_value(transform, source_type, value):
+ """year, month, day, and hour as ordinals from the Unix epoch, rounded
down."""
+ if not isinstance(value, str):
+ raise ValueError(f"{source_type} must be an ISO string")
+ if source_type == "date":
+ if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", value):
+ raise ValueError("date must use YYYY-MM-DD")
+ day = date.fromisoformat(value)
+ hours = None
+ else:
+ match = TIMESTAMP.fullmatch(value)
+ if not match or bool(match[3]) !=
source_type.startswith("timestamptz"):
+ raise ValueError("timestamp zone must match source type")
+ if match[2] and len(match[2]) > (9 if source_type.endswith("_ns") else
6):
+ raise ValueError("timestamp exceeds source type precision")
+ # Floor division is unambiguous for hour and day; epoch_units refuses
the
+ # same negative sub-microsecond input for bucket, where the spec does
not
+ # say how to round to microseconds before hashing.
+ nanoseconds = epoch_nanos(value)
+ hours = nanoseconds // 3_600_000_000_000
+ day = date(1970, 1, 1) + timedelta(days=nanoseconds //
86_400_000_000_000)
+ if transform == "year":
+ return day.year - 1970
+ if transform == "month":
+ return (day.year - 1970) * 12 + day.month - 1
+ if transform == "day":
+ return day.isoformat()
+ if transform == "hour" and hours is not None:
+ return hours
+ raise ValueError(f"unsupported {transform} source type: {source_type}")
+
+
+UNCHECKED = object()
+
+
+def expected_value(transform, source_type, value):
+ """Recompute a transform result from the spec, or UNCHECKED for a
transform not recomputed."""
+ bucket = re.fullmatch(r"bucket\[([1-9][0-9]*)\]", transform)
+ truncate = re.fullmatch(r"truncate\[([1-9][0-9]*)\]", transform)
+ if _transform_family(transform) not in ("bucket", "truncate", "year",
"month", "day", "hour"):
+ return UNCHECKED
+ if not (bucket or truncate or transform in ("year", "month", "day",
"hour")):
+ raise ValueError(f"malformed transform {json.dumps(transform)}")
+ if value is None:
+ return None
+ if bucket:
+ return bucket_value(int(bucket[1]), source_type, value)
+ if truncate:
+ return truncate_value(int(truncate[1]), source_type, value)
+ return temporal_value(transform, source_type, value)
+
+
+def _computed_value_errors(path, doc):
+ check_appendix_b_vectors()
+
errors = []
for case_index, case in enumerate(doc["cases"]):
- width = re.fullmatch(r"bucket\[([1-9][0-9]*)\]",
case["input"]["transform"])
- if not width:
- continue
- count = int(width[1])
+ transform = case["input"]["transform"]
source_type = case["input"]["source_type"]
values = case["input"]["values"]
expected = case["decoded"]["values"]
for index, (value, wanted) in enumerate(zip(values, expected)):
try:
- actual = None
- if value is not None:
- hashed = murmur3_x86_32(encode_for_hash(source_type,
value))
- actual = (hashed & 0x7FFFFFFF) % count
+ actual = expected_value(transform, source_type, value)
except (TypeError, ValueError, OverflowError, UnicodeError,
struct.error) as exc:
errors.append(f"{path}:
cases/{case_index}/input/values/{index}: {exc}")
continue
- if actual != wanted:
+ if actual is UNCHECKED:
+ break
+ if not _json_scalar_equal(actual, wanted):
errors.append(
f"{path}: cases/{case_index}/decoded/values/{index}: "
- f"expected {actual}, found {wanted}"
+ f"expected {json.dumps(actual)}, found
{json.dumps(wanted)}"
)
return errors
@@ -434,7 +545,7 @@ def main():
if _is_partition_transforms_surface(path):
errors.extend(
_partition_transform_errors(
- path, doc, check_bucket=len(errors) == file_error_count
+ path, doc, check_values=len(errors) == file_error_count
)
)
diff --git a/table-spec/partition-transforms/README.md
b/table-spec/partition-transforms/README.md
index 975e9ed..5ef0428 100644
--- a/table-spec/partition-transforms/README.md
+++ b/table-spec/partition-transforms/README.md
@@ -50,7 +50,11 @@ Consumers subscribe by subdirectory:
taking modulo `N`.
- `truncate/` - integer, long, decimal, string, and binary truncation.
- `year/`, `month/`, `day/`, and `hour/` - temporal ordinals from the Unix
- epoch. `day` expected values are logical dates.
+ epoch. `day` expected values are logical dates. A pre-epoch value maps to the
+ period that contains it, so `1969-12-31T23:59:59.999999` is hour `-1` and
+ `1968-12-31` is year `-2`. The specification leaves the direction of negative
+ rounding open; these cases follow the floor semantics that Java's
`DateTimeUtil`
+ also uses, so rounding toward zero fails them.
- `void/` - "Always produces `null`."
The subdirectories are independent subscription boundaries. For example, an
@@ -147,11 +151,14 @@ the specified sign-bit rule. The values were
independently cross-checked
against Apache Iceberg Java transform tests and PyIceberg transform tests.
Those
implementations are cross-checks, not the source of truth.
-Run `make validate` to recompute every value in `bucket/cases.json` from
-Appendix B's type encodings and Murmur3 x86 32-bit hash. The calculation in
+Run `make validate` to recompute every `bucket`, `truncate`, `year`, `month`,
+`day`, and `hour` value from its input. Bucket values come from Appendix B's
+type encodings and Murmur3 x86 32-bit hash; truncate values follow Truncate
+Transform Details, with a positive remainder; temporal values count whole
+periods from the Unix epoch, rounding down. The calculation in
`dev/validate-fixtures.py` uses only Python's standard library. The validator
-reads fixtures without changing them and fails if a value differs. `make check`
-runs the validator too.
+reads fixtures without changing them and fails if a value differs, labeling
+the case and value index. `make check` runs the validator too.
Appendix B labels the date operation `hashInt(days)`, but its published date
hash vector uses the 8-byte `hashLong(days)` encoding, consistent with its
int/long hash rule; the checker follows the published vector.
diff --git a/table-spec/partition-transforms/day/cases.json
b/table-spec/partition-transforms/day/cases.json
index 191fec8..39a7969 100644
--- a/table-spec/partition-transforms/day/cases.json
+++ b/table-spec/partition-transforms/day/cases.json
@@ -6,11 +6,29 @@
"input": {
"transform": "day",
"source_type": "date",
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
"decoded": {
"result_types": ["date"],
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
"clause": "Partition Transforms: extract a date day, as days from
1970-01-01; expected values are logical dates",
"spec_ref": "format/spec.md#partition-transforms"
@@ -24,6 +42,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999",
+ "1969-01-01T00:00:00",
+ "1968-12-31T23:59:59.999999",
"1970-01-01T00:00:00",
"2000-02-29T23:59:59.999999",
"2000-03-01T00:00:00",
@@ -32,7 +52,16 @@
},
"decoded": {
"result_types": ["date"],
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
"clause": "Partition Transforms: extract a timestamp day; expected
values are logical dates",
"spec_ref": "format/spec.md#partition-transforms"
@@ -46,6 +75,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999Z",
+ "1969-01-01T00:00:00Z",
+ "1968-12-31T23:59:59.999999Z",
"1970-01-01T00:00:00Z",
"2000-02-29T23:59:59.999999Z",
"2000-03-01T00:00:00Z",
@@ -59,6 +90,8 @@
"values": [
null,
"1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
"1970-01-01",
"2000-02-29",
"2000-03-01",
@@ -79,6 +112,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999999",
+ "1969-01-01T00:00:00.000000000",
+ "1968-12-31T23:59:59.999999999",
"1970-01-01T00:00:00.000000000",
"2000-02-29T23:59:59.999999999",
"2000-03-01T00:00:00.000000000",
@@ -87,7 +122,16 @@
},
"decoded": {
"result_types": ["date"],
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
"clause": "Partition Transforms: extract a nanosecond timestamp day;
expected values are logical dates",
"spec_ref": "format/spec.md#partition-transforms"
@@ -101,6 +145,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999999Z",
+ "1969-01-01T00:00:00.000000000Z",
+ "1968-12-31T23:59:59.999999999Z",
"1970-01-01T00:00:00.000000000Z",
"2000-02-29T23:59:59.999999999Z",
"2000-03-01T00:00:00.000000000Z",
@@ -114,6 +160,8 @@
"values": [
null,
"1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
"1970-01-01",
"2000-02-29",
"2000-03-01",
diff --git a/table-spec/partition-transforms/hour/cases.json
b/table-spec/partition-transforms/hour/cases.json
index f75fb44..52e0f97 100644
--- a/table-spec/partition-transforms/hour/cases.json
+++ b/table-spec/partition-transforms/hour/cases.json
@@ -9,13 +9,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999",
+ "1969-12-31T23:00:00",
+ "1969-12-31T22:59:59.999999",
"1970-01-01T00:00:00",
"2000-02-29T23:59:59.999999",
"2000-03-01T00:00:00",
"2017-12-01T10:12:55.038194"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 264407,
264408, 420034] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
264407, 264408, 420034] },
"clause": "Partition Transforms: extract a timestamp hour, as hours from
1970-01-01 00:00:00",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -28,6 +30,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999Z",
+ "1969-12-31T23:00:00Z",
+ "1969-12-31T22:59:59.999999Z",
"1970-01-01T00:00:00Z",
"2000-02-29T23:59:59.999999Z",
"2000-03-01T00:00:00Z",
@@ -36,7 +40,7 @@
"2017-11-30T23:30:00-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 264407,
264408, 420034, 420034, 420033] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
264407, 264408, 420034, 420034, 420033] },
"clause": "Partition Transforms: timestamp-with-zone hour uses the
instant across equivalent offsets and a local-date crossing",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -49,13 +53,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999999",
+ "1969-12-31T23:00:00.000000000",
+ "1969-12-31T22:59:59.999999999",
"1970-01-01T00:00:00.000000000",
"2000-02-29T23:59:59.999999999",
"2000-03-01T00:00:00.000000000",
"2017-12-01T10:12:55.038194789"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 264407,
264408, 420034] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
264407, 264408, 420034] },
"clause": "Partition Transforms: extract a nanosecond timestamp hour, as
hours from the Unix epoch",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -68,6 +74,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999999Z",
+ "1969-12-31T23:00:00.000000000Z",
+ "1969-12-31T22:59:59.999999999Z",
"1970-01-01T00:00:00.000000000Z",
"2000-02-29T23:59:59.999999999Z",
"2000-03-01T00:00:00.000000000Z",
@@ -76,7 +84,7 @@
"2017-11-30T23:30:00.000000001-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 264407,
264408, 420034, 420034, 420033] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
264407, 264408, 420034, 420034, 420033] },
"clause": "Partition Transforms: zoned nanosecond timestamp hour uses
the instant across offsets",
"spec_ref": "format/spec.md#partition-transforms"
}
diff --git a/table-spec/partition-transforms/month/cases.json
b/table-spec/partition-transforms/month/cases.json
index 30fa378..024de09 100644
--- a/table-spec/partition-transforms/month/cases.json
+++ b/table-spec/partition-transforms/month/cases.json
@@ -6,9 +6,18 @@
"input": {
"transform": "month",
"source_type": "date",
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 361, 362,
575] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -12, -13, 0,
361, 362, 575] },
"clause": "Partition Transforms: extract a date month, as months from
1970-01-01",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -21,13 +30,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999",
+ "1969-01-01T00:00:00",
+ "1968-12-31T23:59:59.999999",
"1970-01-01T00:00:00",
"2000-02-29T23:59:59.999999",
"2000-03-01T00:00:00",
"2017-12-01T10:12:55.038194"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 361, 362,
575] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -12, -13, 0,
361, 362, 575] },
"clause": "Partition Transforms: extract a timestamp month, as months
from 1970-01-01",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -40,6 +51,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999Z",
+ "1969-01-01T00:00:00Z",
+ "1968-12-31T23:59:59.999999Z",
"1970-01-01T00:00:00Z",
"2000-02-29T23:59:59.999999Z",
"2000-03-01T00:00:00Z",
@@ -48,7 +61,7 @@
"2017-11-30T23:30:00-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 361, 362,
575, 575, 575] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -12, -13, 0,
361, 362, 575, 575, 575] },
"clause": "Partition Transforms: timestamp-with-zone month uses the
instant across offset-equivalent values and date boundaries",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -61,13 +74,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999999",
+ "1969-01-01T00:00:00.000000000",
+ "1968-12-31T23:59:59.999999999",
"1970-01-01T00:00:00.000000000",
"2000-02-29T23:59:59.999999999",
"2000-03-01T00:00:00.000000000",
"2017-12-01T10:12:55.038194789"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 361, 362,
575] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -12, -13, 0,
361, 362, 575] },
"clause": "Partition Transforms: extract a nanosecond timestamp month,
as months from 1970-01-01",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -80,6 +95,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999999Z",
+ "1969-01-01T00:00:00.000000000Z",
+ "1968-12-31T23:59:59.999999999Z",
"1970-01-01T00:00:00.000000000Z",
"2000-02-29T23:59:59.999999999Z",
"2000-03-01T00:00:00.000000000Z",
@@ -88,7 +105,7 @@
"2017-11-30T23:30:00.000000001-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 361, 362,
575, 575, 575] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -12, -13, 0,
361, 362, 575, 575, 575] },
"clause": "Partition Transforms: zoned nanosecond timestamp month uses
the instant across offsets",
"spec_ref": "format/spec.md#partition-transforms"
}
diff --git a/table-spec/partition-transforms/year/cases.json
b/table-spec/partition-transforms/year/cases.json
index 26c4327..3a52b0a 100644
--- a/table-spec/partition-transforms/year/cases.json
+++ b/table-spec/partition-transforms/year/cases.json
@@ -6,9 +6,18 @@
"input": {
"transform": "year",
"source_type": "date",
- "values": [null, "1969-12-31", "1970-01-01", "2000-02-29",
"2000-03-01", "2017-12-01"]
+ "values": [
+ null,
+ "1969-12-31",
+ "1969-01-01",
+ "1968-12-31",
+ "1970-01-01",
+ "2000-02-29",
+ "2000-03-01",
+ "2017-12-01"
+ ]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 30, 30,
47] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
30, 30, 47] },
"clause": "Partition Transforms: extract a date year, as years from
1970",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -21,13 +30,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999",
+ "1969-01-01T00:00:00",
+ "1968-12-31T23:59:59.999999",
"1970-01-01T00:00:00",
"2000-02-29T23:59:59.999999",
"2000-03-01T00:00:00",
"2017-12-01T10:12:55.038194"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 30, 30,
47] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
30, 30, 47] },
"clause": "Partition Transforms: extract a timestamp year, as years from
1970",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -40,6 +51,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999Z",
+ "1969-01-01T00:00:00Z",
+ "1968-12-31T23:59:59.999999Z",
"1970-01-01T00:00:00Z",
"2000-02-29T23:59:59.999999Z",
"2000-03-01T00:00:00Z",
@@ -48,7 +61,7 @@
"2017-11-30T23:30:00-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 30, 30,
47, 47, 47] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
30, 30, 47, 47, 47] },
"clause": "Partition Transforms: timestamp-with-zone year uses the
instant; equivalent instants and an offset date crossing are included",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -61,13 +74,15 @@
"values": [
null,
"1969-12-31T23:59:59.999999999",
+ "1969-01-01T00:00:00.000000000",
+ "1968-12-31T23:59:59.999999999",
"1970-01-01T00:00:00.000000000",
"2000-02-29T23:59:59.999999999",
"2000-03-01T00:00:00.000000000",
"2017-12-01T10:12:55.038194789"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 30, 30,
47] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
30, 30, 47] },
"clause": "Partition Transforms: extract a nanosecond timestamp year, as
years from 1970",
"spec_ref": "format/spec.md#partition-transforms"
},
@@ -80,6 +95,8 @@
"values": [
null,
"1969-12-31T23:59:59.999999999Z",
+ "1969-01-01T00:00:00.000000000Z",
+ "1968-12-31T23:59:59.999999999Z",
"1970-01-01T00:00:00.000000000Z",
"2000-02-29T23:59:59.999999999Z",
"2000-03-01T00:00:00.000000000Z",
@@ -88,7 +105,7 @@
"2017-11-30T23:30:00.000000001-10:00"
]
},
- "decoded": { "result_types": ["int"], "values": [null, -1, 0, 30, 30,
47, 47, 47] },
+ "decoded": { "result_types": ["int"], "values": [null, -1, -1, -2, 0,
30, 30, 47, 47, 47] },
"clause": "Partition Transforms: zoned nanosecond timestamp year uses
the instant across offsets",
"spec_ref": "format/spec.md#partition-transforms"
}