Skip to content

Conversation

@uddhavdave
Copy link
Contributor

Simplifies the wal reader filters and add tests cases

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Failed to generate code suggestions for PR

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Dec 1, 2025
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

This PR fixes date validation in the WAL directory datetime filter by replacing manual leap year calculation with chrono's with_ymd_and_hms API, which correctly handles all edge cases including century years (1900 is not a leap year, 2000 is).

  • Bug fix: The previous implementation used year % 4 == 0 for leap year detection, which incorrectly treated 1900 as a leap year. Chrono handles the full leap year rules (divisible by 4, but not by 100 unless also divisible by 400).
  • Behavior change: Modified the default day logic for incomplete paths to use day=1 for months different from start_time, enabling proper directory traversal across month boundaries.
  • Test coverage: Added comprehensive tests for leap year edge cases (2024, 2000 as valid; 2023, 1900 as invalid), invalid calendar dates (April 31, June 31, etc.), and month boundary transitions.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a real bug in leap year handling and adds comprehensive tests.
  • The changes are well-scoped, fixing a legitimate bug in date validation by delegating to the battle-tested chrono library. The new tests thoroughly cover leap year edge cases (including century years like 1900/2000), invalid calendar dates, and month boundaries. The logic changes are correct and improve the robustness of the WAL file scanning.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
src/config/src/utils/async_file.rs 5/5 Improved date validation by using chrono's with_ymd_and_hms for proper leap year handling, fixed day default logic for cross-month directory traversal, and added comprehensive test coverage for edge cases (leap years, invalid dates like Feb 29 on non-leap years, April 31).

Sequence Diagram

sequenceDiagram
    participant Client
    participant search_parquet
    participant get_file_list
    participant create_wal_dir_datetime_filter
    participant scan_files_filtered
    participant chrono

    Client->>search_parquet: Query with time_range
    search_parquet->>get_file_list: Get files in time range
    get_file_list->>create_wal_dir_datetime_filter: Create filter(start_time, end_time)
    create_wal_dir_datetime_filter-->>get_file_list: Return filter closure
    get_file_list->>scan_files_filtered: Scan with filter
    
    loop For each path
        scan_files_filtered->>create_wal_dir_datetime_filter: Apply filter(path)
        create_wal_dir_datetime_filter->>chrono: with_ymd_and_hms(year, month, day, hour)
        chrono-->>create_wal_dir_datetime_filter: Valid datetime or None
        create_wal_dir_datetime_filter-->>scan_files_filtered: true/false
    end
    
    scan_files_filtered-->>get_file_list: Filtered file list
    get_file_list-->>search_parquet: FileKey list
    search_parquet-->>Client: Search results
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@uddhavdave uddhavdave added this to the v0.30.0 milestone Dec 2, 2025
@hengfeiyang hengfeiyang merged commit aff58b3 into main Dec 4, 2025
52 of 54 checks passed
@hengfeiyang hengfeiyang deleted the ud/fix-async-file branch December 4, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants