Skip to content

feat(dates): adding handling for first of#37098

Merged
alexandrusoare merged 3 commits into
masterfrom
alexandrusoare/feat/date-parse-improvements
Jan 15, 2026
Merged

feat(dates): adding handling for first of#37098
alexandrusoare merged 3 commits into
masterfrom
alexandrusoare/feat/date-parse-improvements

Conversation

@alexandrusoare
Copy link
Copy Markdown
Contributor

@alexandrusoare alexandrusoare commented Jan 13, 2026

SUMMARY

Add support for parsing "first of the month" and similar expressions in time filters.

Single date expressions:

  • "first of the month" → Nov 1
  • "first of this month" → Nov 1
  • "first of last month" → Oct 1
  • "first day of this week" → Nov 7

Range expressions:

  • "first week of this year" → Jan 1 to Jan 8
  • "first month of the quarter" → Oct 1 to Nov 1

The key distinction is that "first of X" and "first day of X" return a single date, while "first week/month/quarter of X" returns a date range.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE

image

AFTER

image

TESTING INSTRUCTIONS

  • Added unit tests for all new expression patterns
  • Verified existing date parser tests still pass

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 13, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit b244049
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69664f78508e3a0008fb9fcd
😎 Deploy Preview https://deploy-preview-37098--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@msyavuz
Copy link
Copy Markdown
Member

msyavuz commented Jan 14, 2026

We are not handling expressions like first two weeks of next month right? Should we? Also i think node has chrono for parsing nl dates, is there anything like that for python?

@alexandrusoare alexandrusoare marked this pull request as ready for review January 14, 2026 10:54
@dosubot dosubot Bot added the change:backend Requires changing the backend label Jan 14, 2026
Copy link
Copy Markdown
Contributor

@bito-code-review bito-code-review Bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #38d2ff

Actionable Suggestions - 1
  • tests/unit_tests/utils/date_parser_tests.py - 1
Review Details
  • Files reviewed - 2 · Commit Range: e46d328..b244049
    • superset/utils/date_parser.py
    • tests/unit_tests/utils/date_parser_tests.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines +619 to +620
result = get_since_until("first of this month : ")
assert result == (datetime(2016, 11, 1), None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing tzinfo argument in datetime call

Line 620 creates a datetime object without tzinfo argument. Add timezone information using datetime(..., tzinfo=timezone.utc) or the project's preferred timezone handling approach.

Code suggestion
Check the AI-generated fix before applying
Suggested change
result = get_since_until("first of this month : ")
assert result == (datetime(2016, 11, 1), None)
result = get_since_until("first of this month : ")
from datetime import timezone
assert result == (datetime(2016, 11, 1, tzinfo=timezone.utc), None)

Code Review Run #38d2ff


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

@alexandrusoare
Copy link
Copy Markdown
Contributor Author

We are not handling expressions like first two weeks of next month right? Should we? Also i think node has chrono for parsing nl dates, is there anything like that for python?

I have also been looking into alternatives for a library that could handle all of these cases so in the future we won t have to add these manually, I have tested the dateparser library but it doesn't cover all of our needs

@yousoph yousoph added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Jan 14, 2026
@github-actions github-actions Bot added 🎪 b244049 🚦 building 🎪 ⌛ 48h Environment expires after 48 hours (default) and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Jan 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for b244049

@github-actions
Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for b244049

Environment: http://44.251.130.183:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@github-actions
Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for a6f1871

Environment: http://16.148.67.235:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jan 15, 2026

Code Review Agent Run #921248

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: b244049..a6f1871
    • superset/utils/date_parser.py
    • tests/unit_tests/utils/date_parser_tests.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@alexandrusoare alexandrusoare merged commit 81fdc2b into master Jan 15, 2026
65 checks passed
@alexandrusoare alexandrusoare deleted the alexandrusoare/feat/date-parse-improvements branch January 15, 2026 17:48
jesperct pushed a commit to jesperct/superset that referenced this pull request Jan 19, 2026
jesperct pushed a commit to jesperct/superset that referenced this pull request Jan 19, 2026
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 24, 2026
(cherry picked from commit 8f35cc93673a56ba499510fbefabf9e4a46d8b6f)
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Mar 5, 2026
alex-poor pushed a commit to alex-poor/superset that referenced this pull request Mar 15, 2026
rusackas pushed a commit that referenced this pull request Apr 17, 2026
- development-setup.md: update Node.js prerequisite from v20 to v22 LTS
  (PR #37223 — project minimum Node version upgraded)
- importing-exporting-datasources.mdx: document that masked_encrypted_extra
  (sensitive connection parameters like service account JSON) is now included
  in database import/export (PR #38078)
- security.mdx: add note that get_samples() enforces datasource-level access
  control, closing prior gap where unprivileged users could fetch sample rows
  (PR #36550)
- exploring-data.mdx: document natural language time range expressions
  including new "first of" expressions (first day/week of month/quarter/year)
  supported in the Custom time range picker (PR #37098)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rusackas pushed a commit that referenced this pull request Apr 17, 2026
- theming.mdx: document ECharts array property overrides (PR #37965) —
  array values like color palettes are fully supported and replaced entirely
  (not merged); adds Array Property Overrides section with color palette example
- configuring-superset.mdx: document PKCE support for database OAuth2
  (PR #37067) — add PKCE section under Custom OAuth2 with code_challenge_method
  config and when to use it
- cache.mdx: document ETag support for thumbnail/screenshot endpoints
  (PR #37663) — conditional GET with If-None-Match to avoid downloading
  unchanged images
- exploring-data.mdx: document SQL Lab UX improvements (PRs #37298, #37694,
  #37756) — treeview table browser, Ctrl+F find widget, resizable panels;
  also adds time range natural language expressions section (PR #37098)
- creating-your-first-dashboard.mdx: document Table chart features — boolean
  and categorical conditional formatting (PRs #36338, #37756), gradient toggle
  (PR #36280), HTML cell rendering with security note (PR #37685), column
  header tooltips from dataset descriptions (PR #37179), Display Controls
  modal in dashboard view (PR #36062)
- databases.json: update StarRocks supports_catalog and supports_dynamic_catalog
  to true — the engine spec (PR #37026) already implemented full catalog support
  with get_catalog_names(), get_default_catalog(), and SHOW CATALOGS; the
  committed JSON was stale and did not reflect this

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend size/L 🎪 ⌛ 48h Environment expires after 48 hours (default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants