← Back to Pull requests

fix: correct hourly period bucket alignment #20941

Closed
unknown closed this pull request without merging on Nov 26, 2026 03:37 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 23:04 UTC
Author

Description

Fix a data correctness issue in hourly PeriodGranularity where certain origin and timezone configurations produce buckets that exclude the input timestamp. This can cause missing results, incorrect result timestamps or query failures.

  • Explicit origins: Preserve the requested alignment. For hourly buckets aligned at :30, 16:10Z belongs in [15:30Z, 16:30Z). The existing negative-origin workaround incorrectly shifts this to [15:00Z, 16:00Z).

  • Omitted origins: Preserve existing whole-local-hour alignment, but align boundaries before selecting the bucket. For two-hour buckets in Kathmandu, 20:10 local must belong in [20:00, 22:00). Previously, Druid selected [18:15, 20:15) and then shifted it to [18:00, 20:00), excluding the timestamp.
  • The fix also rounds timestamps before the origin down correctly and makes each bucket end at the next aligned boundary across timezone offset changes.

    Validation

  • 4,480 granularity, cursor, and timeseries tests passed.

  • Existing Kathmandu and Dhaka expectations remain unchanged.

  • Forbidden-API checks, targeted Checkstyle, and whitespace checks passed.
  • Release note

  • Fix hourly period bucketing that could cause missing results, shifted timestamps, or query failures.

  • Explicit origins before the Unix epoch now retain their requested alignment. For example, :30 boundaries instead of incorrectly rounded :00 boundaries.

  • With no origin, affected multi-hour queries now select the correct containing bucket. For example, Kathmandu 20:10 moves from [18:00, 20:00) to [20:00, 22:00).
  • ##### Key changed classes

  • PeriodGranularity

  • QueryGranularityTest
  • This PR has:

  • been self-reviewed.

  • a release note entry in the PR description.

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • Diff: 261 lines (+195 / -66) across 3 files Reviewer: maytasm Review duration: 8912m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.44) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 261 lines diff across 3 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.333
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #20941"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.2% (MEDIUM) · Higher = larger blast radius
    44.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.1% · Safe to merge
    19.1%
    Repository