Skip to content

fix: replace DuckDB-style quoted INTERVAL literals with BigQuery syntax#142

Merged
C00ldudeNoonan merged 1 commit into
mainfrom
fix/issue-139-bigquery-interval-syntax
Jul 11, 2026
Merged

fix: replace DuckDB-style quoted INTERVAL literals with BigQuery syntax#142
C00ldudeNoonan merged 1 commit into
mainfrom
fix/issue-139-bigquery-interval-syntax

Conversation

@C00ldudeNoonan

Copy link
Copy Markdown
Owner

Summary

Fixes #139 — replaces DuckDB/Postgres-style quoted INTERVAL '3 years' literals with BigQuery's native unquoted INTERVAL 3 YEAR syntax across all instances found in the codebase.

Why the error was confusing

BigQuery's parser doesn't fail cleanly at the malformed INTERVAL — it loses sync and reports the error at the next clause, almost always ORDER BY:

400 Syntax error: Unexpected keyword ORDER at [7:9]

That pointed everywhere except the actual bug, which is why 4+ jobs sat broken.

Files changed

  • signals/fear_greed_composite.py — 6 occurrences via an f-string lookback variable, changed to an int (lookback_years = 3)
  • signals/entropy_complexity.py, signals/absorption_ratio.py, signals/network_correlation.py — hardcoded literals
  • domains/sec/cik_history.pyINTERVAL '90 days'INTERVAL 90 DAY
  • analysis/economy_state/domain_data_fetchers.py, analysis/economy_state/data_access.py — 7 occurrences total, all driven by an existing int parameter (max_months, months_per_series, months_limit), confirmed by reading each function signature before editing

Verification

Ran each of the 4 job-level fixes directly against a live BigQuery target (dagster job execute) before and after the fix:

Job Before After
fear_greed_job 400 Syntax error: Unexpected keyword ORDER syntax error gone — now fails on an unrelated pre-existing bug (unqualified stg_major_indices reference resolves to the wrong dataset; filed separately)
entropy_complexity_job same syntax error same — now hits the same unrelated stg_* dataset bug
absorption_ratio_job same syntax error syntax error gone — now fails only because this local dev environment's BigQuery dataset was never backfilled with sp500_companies_prices_raw (a data gap specific to this sandbox, not a code defect — that table exists in the prod dataset)
network_correlation_job same syntax error same as absorption_ratio_job

No remaining INTERVAL '...' (quoted) instances anywhere in macro_agents/src — confirmed by repo-wide grep.

Not in scope here

Filed separately since they're distinct root causes surfaced only after this fix removed the syntax error masking them: unqualified stg_* table references in fear_greed_composite.py/entropy_complexity.py resolving against the wrong BigQuery dataset.

🤖 Generated with Claude Code

…ax (#139)

BigQuery rejects `INTERVAL '3 years'` (quoted string, DuckDB/Postgres
style) with a confusing downstream parse error reported at the next
clause rather than at the INTERVAL itself. The fix is BigQuery's native
unquoted form: `INTERVAL 3 YEAR`.

Fixed 4 confirmed-broken jobs plus 3 more instances found by inspection:

- signals/fear_greed_composite.py (6 occurrences, f-string lookback var)
- signals/entropy_complexity.py
- signals/absorption_ratio.py
- signals/network_correlation.py
- domains/sec/cik_history.py
- analysis/economy_state/domain_data_fetchers.py (4 occurrences)
- analysis/economy_state/data_access.py (3 occurrences)

Verified by running each of the 4 job-level fixes directly against a
live BigQuery target (dagster job execute) before and after: all four
previously failed with "Syntax error: Unexpected keyword ORDER"; after
the fix, none show that error. fear_greed_job and entropy_complexity_job
now fail on an unrelated, separate bug (unqualified stg_* table
references resolving to the wrong dataset — filed separately);
absorption_ratio_job and network_correlation_job now fail only because
this local dev environment's BigQuery dataset has never been backfilled
with sp500_companies_prices_raw (data gap, not a code defect).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@C00ldudeNoonan
C00ldudeNoonan merged commit 1e5402e into main Jul 11, 2026
1 check passed
@C00ldudeNoonan
C00ldudeNoonan deleted the fix/issue-139-bigquery-interval-syntax branch July 11, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQuery-invalid INTERVAL syntax breaks 4+ signal jobs (fear_greed, entropy_complexity, absorption_ratio, network_correlation)

1 participant