Skip to content

fix(gsheets): correctly format Date-column filter literals - #43355

Merged
rusackas merged 4 commits into
masterfrom
fix-gsheets-date-column-previous-month-filter
Aug 24, 2026
Merged

fix(gsheets): correctly format Date-column filter literals#43355
rusackas merged 4 commits into
masterfrom
fix-gsheets-date-column-previous-month-filter

Conversation

@sadpandajoe

@sadpandajoe sadpandajoe commented Aug 20, 2026

Copy link
Copy Markdown
Member

SUMMARY

Filtering a Date-typed column on a Google Sheets-backed dataset (for example, a built-in "Previous Calendar Month" time range) raised Invalid query: NO_COLUMN: null. GSheetsEngineSpec inherited SqliteEngineSpec.convert_dttm, which only handles String/DateTime SQLAlchemy types and returns None for Date. Superset then fell back to a full 'YYYY-MM-DD HH:MM:SS.ffffff' literal for the filter bound, even for a pure Date column. Shillelagh's ISODate parser (used internally by the GSheets adapter to turn the SQL literal into a filter value) rejects the trailing time-of-day and silently returns None, which the adapter then renders as the bare, unquoted literal null in the generated query. Google's API parses that bareword as a column reference rather than a NULL value, producing exactly the reported error.

This adds a GSheetsEngineSpec.convert_dttm override that emits a plain 'YYYY-MM-DD' literal for Date columns (no TO_DATE()-style wrapper needed, since shillelagh's query layer is SQLite/apsw, not Postgres), matching the format the adapter actually parses. DateTime columns are unaffected — they already go through the inherited, working code path.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend query-generation fix, no UI change.

TESTING INSTRUCTIONS

  • pytest tests/unit_tests/db_engine_specs/test_gsheets.py -k test_convert_dttm — new parametrized test covering Date, DateTime, and an unrecognized type. The Date case fails on master (AssertionError: None) and passes with this change.
  • Full tests/unit_tests/db_engine_specs/ and tests/unit_tests/models/helpers_test.py suites pass with no new failures.

ADDITIONAL INFORMATION

  • Has associated issue: related to Cannot Apply Filter in Dashboard to Google Sheet Data Source #30413 (same NO_COLUMN: null error reported for Google Sheets dashboard filters generally; this fixes the mechanism for Date-typed columns specifically)
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

sadpandajoe and others added 2 commits August 20, 2026 05:03
GSheetsEngineSpec inherited SqliteEngineSpec.convert_dttm, which returns
None for types.Date, so Superset fell back to a datetime-with-microseconds
literal for Date-typed filter bounds. shillelagh's virtual table layer
parses that value with datetime.date.fromisoformat, which rejects the
trailing time and silently drops it to None, causing the GSheets adapter
to embed a bare, unquoted `null` literal in the query sent to Google's
API instead of a real value -- producing "Invalid query: NO_COLUMN: null".

Override convert_dttm on GSheetsEngineSpec to emit a plain 'YYYY-MM-DD'
literal for Date columns, which shillelagh can parse and quote correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add a standalone, runnable script plus its captured before/after output
as an appendix, and point every "verified" claim in the root-cause trace
at it, so the analysis is auditable from the tracked file alone rather
than resting on unrecorded local runs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.73%. Comparing base (b5fe00b) to head (7de8d53).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
superset/db_engine_specs/gsheets.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43355      +/-   ##
==========================================
- Coverage   66.74%   66.73%   -0.02%     
==========================================
  Files        2876     2876              
  Lines      164228   164226       -2     
  Branches    37891    37889       -2     
==========================================
- Hits       109617   109593      -24     
- Misses      52453    52474      +21     
- Partials     2158     2159       +1     
Flag Coverage Δ
hive 38.11% <50.00%> (+<0.01%) ⬆️
mysql 57.76% <50.00%> (-0.01%) ⬇️
postgres 57.80% <50.00%> (-0.01%) ⬇️
presto 40.04% <50.00%> (+<0.01%) ⬆️
python 59.18% <50.00%> (-0.01%) ⬇️
sqlite 57.44% <50.00%> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pull-request-size pull-request-size Bot added size/M and removed size/L labels Aug 20, 2026
@netlify

netlify Bot commented Aug 20, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7de8d53
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a8759e143cea1000859635f
😎 Deploy Preview https://deploy-preview-43355--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@sadpandajoe
sadpandajoe marked this pull request as ready for review August 20, 2026 19:47
@dosubot dosubot Bot added the data:connect:googlesheets Related to Google Sheets label Aug 20, 2026
@bito-code-review

bito-code-review Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1a1b1b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 69658f3..7de8d53
    • superset/db_engine_specs/gsheets.py
    • tests/unit_tests/db_engine_specs/test_gsheets.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ 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

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Narrow, well-scoped fix — only intercepts types.Date, so the working DateTime path through SqliteEngineSpec.convert_dttm is untouched. Test reuses the shared assert_convert_dttm helper and covers Date/DateTime/unknown-type, and I confirmed it fails on master per the PR description. CI's green.

@rusackas
rusackas merged commit 24b95f9 into master Aug 24, 2026
77 checks passed
@rusackas
rusackas deleted the fix-gsheets-date-column-previous-month-filter branch August 24, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants