Skip to content

fix(vikingdb): normalize all date_time range filters in API key client - #3973

Open
fengluodb wants to merge 2 commits into
mainfrom
fix/normalize-date-time-filters-api-key
Open

fix(vikingdb): normalize all date_time range filters in API key client#3973
fengluodb wants to merge 2 commits into
mainfrom
fix/normalize-date-time-filters-api-key

Conversation

@fengluodb

Copy link
Copy Markdown
Collaborator

Description

Supersedes #3954. Fix date filtering for the commercial VikingDB data plane that uses Bearer API-key authentication.

OpenViking compiles TimeRange down to the internal range DSL, but the commercial data plane expects time_range for date_time fields and range only for numeric fields. The API-key client does not run the local engine filter conversion, so range nodes on date_time fields were sent verbatim and mis-handled.

Why this differs from #3954

#3954 only normalized the created_at field via a hardcoded literal. The context collection schema has two date_time fields, created_at and updated_at, and updated_at is the default time_field for the public find/search API. Hardcoding created_at leaves updated_at range filters broken and is fragile against schema evolution.

Changes Made

  • Normalize range -> time_range for every schema date_time field by reusing the canonical VALID_TIME_FIELDS constant (created_at + updated_at) instead of a hardcoded field name.
  • Preserve numeric range nodes and nested boolean filter structure.
  • Pass through filters already emitted as time_range unchanged (idempotent).
  • Apply the conversion only to the request body filter; upsert/update data untouched.
  • Add regression tests for converted created_at/updated_at date filters, an unchanged numeric filter, and time_range idempotency.

Testing

  • uvx ruff check / uvx ruff format --check pass on both files.
  • Focused suite: 23 passed. (4 pre-existing failures in test_volcengine_clients.py about ignore_unknown_fields reproduce on the base branch and are unrelated to this change.)

fengluodb and others added 2 commits August 13, 2026 14:36
OpenViking compiles TimeRange down to the internal `range` DSL, but the
commercial VikingDB data plane (Bearer API-key auth) expects `time_range`
for date_time fields and `range` only for numeric fields. The API-key
client does not run the local engine's filter conversion, so `range`
nodes on date_time fields were sent verbatim and mis-handled.

Normalize `range` -> `time_range` for every schema date_time field by
reusing the canonical VALID_TIME_FIELDS constant, covering both
`created_at` and `updated_at` instead of hardcoding a single field name.
Numeric `range` nodes and nested boolean filter structure are preserved,
and filters already emitted as `time_range` pass through unchanged. Only
the request body `filter` is rewritten; upsert/update data is untouched.

Add regression tests covering the converted created_at/updated_at date
filters, an unchanged numeric filter, and time_range idempotency.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
The API-key client already rewrites `range` filter nodes on date_time
fields to VikingDB's `time_range` operator, but the AK/SK-signed
`VolcengineCollection` shares the same commercial data-plane endpoints
and had the identical latent bug: `TimeRange` expressions compile down
to the internal `range` DSL, which the commercial API only accepts for
numeric fields.

Mirror the API-key fix in `VolcengineCollection._data_post` so both
auth modes normalize `range` -> `time_range` for `created_at`/`updated_at`
while leaving numeric `range` nodes untouched. Add AK/SK coverage for
both date_time fields and for idempotency of already-`time_range` input.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants