fix(weave): normalize datetime literals in feedback/ORM query path#6991
Open
gtarpenning wants to merge 3 commits into
Open
fix(weave): normalize datetime literals in feedback/ORM query path#6991gtarpenning wants to merge 3 commits into
gtarpenning wants to merge 3 commits into
Conversation
feedback_query 500'd on created_at filters because ISO-8601 strings with a T separator / Z suffix can't be compared against a DateTime64 column (TYPE_MISMATCH, code 53). The generic ORM where-path now normalizes datetime-column literals to ClickHouse's canonical YYYY-MM-DD HH:MM:SS.ffffff form, mirroring the calls query builder. The shared datetime helpers and the operand converter move down into orm.py (the base layer both paths depend on); the calls path delegates to the shared maybe_convert_datetime_operands. WB-34897 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…operands Move maybe_convert_datetime_operands into process_binary_operands (the single chokepoint for all five comparison ops) instead of calling it at each branch, and drop the redundant date-only branch in parse_string_to_utc_timestamp -- datetime.fromisoformat already parses YYYY-MM-DD as naive midnight, which the existing naive-as-UTC path handles identically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Query real fields (id, feedback_type, payload) and assert on the returned row instead of only count(*), so the datetime-filter path is exercised as a full round-trip. Also trim an overclaim in the maybe_convert_datetime_operands docstring (index pruning is table- dependent, not guaranteed in the generic ORM path). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
feedback_query500'd oncreated_atfilters: ISO-8601 strings carrying aTseparator /Zsuffix (e.g.2026-05-27T17:49:15.491230Z) can't be compared against theDateTime64(3)column, so ClickHouse raises TYPE_MISMATCH (code 53). The generic ORMwherepath now normalizes datetime-column literals to ClickHouse's canonicalYYYY-MM-DD HH:MM:SS.ffffffform, mirroring the existing calls-query-builder fix.parse_string_to_utc_timestamp,timestamp_to_datetime_str) and the operand converter move down intoorm.py(the base layer both paths import;calls_query_buildercan't be imported back intoorm). The calls path now delegates to the sharedmaybe_convert_datetime_operandsinstead of its own copy.$eq/$gt/$lt/$gte/$lte) normalize datetime literals, matching the calls path.$inagainst a datetime column is unchanged (different operand shape, and exact-timestampINlists aren't a real query pattern).Testing
unit coverage in test_orm.py for the conversion (incl. a non-datetime-column control) + a functional feedback_query test that filters on
created_atand asserts on the returned row; calls path delegates to the shared helper so existing calls coverage applies.