feat(types): add datetime.date and datetime.datetime support for Tag values (ITL-45) - #188
Conversation
starfix 0.4.0 adds support for hashing pa.timestamp Arrow types, which is required for content_hash() to work on Tags containing datetime values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR formalizes datetime.date and datetime.datetime as supported Tag value types by aligning public type aliases with the Arrow conversion layer, and by upgrading starfix so content_hash() can hash Arrow timestamp columns.
Changes:
- Bump
starfixto~=0.4.0to enable hashing forpa.timestamp(...)columns used by datetime-valued Tags. - Extend
UniversalTypeConverterwith an explicitdate ↔ pa.date32()mapping (and reverse mapping viapa.types.is_date). - Update public type aliases (
TagValue,SupportedNativePythonData) and add integration/unit tests covering construction, round-trip, schema inference, and hashing for date/datetime Tag values.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Bumps starfix to ~=0.4.0 to support timestamp hashing. |
uv.lock |
Locks the resolved starfix==0.4.0 artifact metadata. |
src/orcapod/semantic_types/universal_converter.py |
Adds direct date → pa.date32() mapping and pa.date* → date reverse mapping. |
src/orcapod/types.py |
Expands public type aliases to include date and datetime. |
test-objective/unit/test_semantic_types.py |
Adds converter tests for date type mapping and schema round-trip. |
test-objective/unit/test_tag.py |
Adds TestTagDatetimeValues integration tests for Tag behavior with date/datetime values. |
superpowers/specs/2026-06-29-itl-45-datetime-tag-values-design.md |
Adds design doc describing goals, scope, and the chosen Arrow mappings. |
superpowers/plans/2026-06-29-itl-45-datetime-tag-values.md |
Adds an implementation plan for the change set and verification steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ctx = _make_context() | ||
| tag = Tag({"dob": date(2024, 1, 15)}, data_context=ctx) | ||
| table = tag.as_table() | ||
| assert pa.types.is_date(table.schema.field("dob").type) |
There was a problem hiding this comment.
Good catch. Changed the assertion to assert table.schema.field("dob").type == pa.date32() — this pins the exact type and will catch any silent regression to date64.
| dt = datetime(2024, 1, 15, 12, 0, 0, tzinfo=timezone.utc) | ||
| tag = Tag({"ts": dt}, data_context=ctx) | ||
| table = tag.as_table() | ||
| assert pa.types.is_timestamp(table.schema.field("ts").type) |
There was a problem hiding this comment.
Good catch. Changed to assert table.schema.field("ts").type == pa.timestamp("us", tz="UTC") — this pins both the microsecond precision and the UTC timezone, fully encoding the converter contract.
- Assert exact `pa.date32()` type in `test_date_tag_as_table_schema` instead
of the weaker `pa.types.is_date()` predicate, preventing silent regressions
to date64
- Assert exact `pa.timestamp("us", tz="UTC")` type in
`test_datetime_tag_as_table_schema` instead of `pa.types.is_timestamp()`,
pinning both the unit and timezone as required by the converter contract
- Fix typo "accomodate" → "accommodate" in the spec and plan docs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review round addressed (commit
|
| Comment | Fix |
|---|---|
test_date_tag_as_table_schema used pa.types.is_date() — too broad |
Changed to == pa.date32() — pins exact type, prevents silent regression to date64 |
test_datetime_tag_as_table_schema used pa.types.is_timestamp() — too broad |
Changed to == pa.timestamp("us", tz="UTC") — pins both precision and timezone per the converter contract |
| Typo "accomodate" in spec doc | Fixed → "accommodate" |
| Typo "accomodate" in plan doc | Fixed → "accommodate" |
All 11 TestTagDatetimeValues tests continue to pass.
Review round (no code changes)The single comment in this round was declined:
No changes pushed. |
Summary
starfixto~=0.4.0, which addspa.timestamphashing support — enablingcontent_hash()on Tags with datetime columnsdatetime.date ↔ pa.date32()bidirectional mapping inUniversalTypeConverter(fixesarrow_type_to_python_type(pa.date32())returningAny)dateanddatetimeto theTagValueandSupportedNativePythonDatapublic type aliases (removes the TODO comment)TestTagDatetimeValuescovering construction, round-trip, Arrow schema, content hashing, naive-datetime rejection, and schema inference for both typesTest plan
uv run pytest test-objective/unit/test_semantic_types.py -k "date" -v— 3 new type-converter tests passuv run pytest test-objective/unit/test_tag.py::TestTagDatetimeValues -v— all 11 integration tests passuv run pytest test-objective/ tests/ -q— full suite: 4341 passed, 56 skipped, 13 xfailedCloses ITL-45
🤖 Generated with Claude Code