Skip to content

Expand test coverage and fix critical bugs in semantic layer#29

Merged
nicosuave merged 1 commit intomainfrom
nicosuave/find-untested-code
Jan 3, 2026
Merged

Expand test coverage and fix critical bugs in semantic layer#29
nicosuave merged 1 commit intomainfrom
nicosuave/find-untested-code

Conversation

@nicosuave
Copy link
Copy Markdown
Member

Summary

This PR expands test coverage from ~1200 to 1419 tests (+219 tests) and fixes 8 critical bugs discovered during testing.

Test Additions

Database adapters (34 new tests): URL parsing edge cases, SQL injection prevention, dialect-specific SQL generation

Format adapters (77 new tests): Comprehensive coverage for Hex, Omni, Rill, and Superset adapters with fixture-based parsing and round-trip verification

Time intelligence (91 tests): Model validation tests plus 21 new SQL execution tests against DuckDB (YoY, MoM, WoW, trailing periods, edge cases)

Symmetric aggregates (43 tests): Proves the symmetric aggregate pattern prevents double-counting in fan-out joins with real SQL execution

Table calculations (79 tests): Running totals, percentiles, formula validation, security tests for code injection prevention

End-to-end integration (36 tests): Full stack execution from YAML/BSL through SQL generation to DuckDB with exact numeric assertions

Critical Bugs Fixed

  1. Ratio metrics ignoring filters - Numerator/denominator now apply their own filters independently
  2. Filter inheritance bug - Unfiltered metrics no longer inherit filters from other metrics in same query
  3. SQL injection vulnerabilities - All database adapters now validate identifiers (Postgres, Snowflake, BigQuery, DuckDB, Databricks, Spark)
  4. Zero offset silent failure - Time intelligence now raises ValidationError instead of silently changing 0→1
  5. Invalid expressions silent failure - Table calculations now validate formula syntax at creation time
  6. Missing percentile type - Implemented percentile calculations with linear interpolation
  7. Rill adapter error handling - Now raises FileNotFoundError for missing paths instead of returning empty graph
  8. Derived metrics missing columns - CTEs now include columns referenced in inline metric SQL (fixes kitchen sink tests)

Test Quality

All new tests are high-value: they execute real SQL, verify exact numeric results, test edge cases (NULLs, empty results, large values, division by zero), and use real fixture files. These tests would catch real regressions.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eced342f2c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sidemantic/sql/generator.py Outdated
@nicosuave nicosuave force-pushed the nicosuave/find-untested-code branch from eced342 to 76f18bd Compare January 3, 2026 21:05
This branch adds comprehensive test coverage for untested modules and fixes critical bugs found during testing:

**Test Additions (+1,377 tests):**
- Database adapters: 34+ tests covering URL parsing, SQL injection prevention, dialect-specific SQL
- Format adapters: 77 new tests for Hex, Omni, Rill, Superset adapters
- Time intelligence: 91 tests including 21 new SQL execution tests with DuckDB
- Symmetric aggregates: 43 tests proving double-counting prevention with real data
- Table calculations: 79 tests covering running totals, percentiles, formula security
- End-to-end integration: 36 tests with full stack execution and numeric verification

**Critical Bug Fixes:**
- Fix ratio metrics ignoring metric-level filters - numerator/denominator now apply filters independently
- Fix filter inheritance bug where unfiltered metrics incorrectly inherited filters from other metrics
- Fix SQL injection vulnerabilities in all database adapters (Postgres, Snowflake, BigQuery, etc.)
- Fix zero offset silently becoming 1 in time intelligence - now raises validation error
- Fix invalid table calculation expressions returning None silently - now validates at creation time
- Implement missing percentile calculation type with linear interpolation
- Fix Rill adapter returning empty graph for missing paths - now raises FileNotFoundError
- Fix derived metrics not extracting column dependencies for CTEs - now handles inline SQL filters

**Test Quality:**
All 1419 tests are high-value: they execute real SQL against DuckDB with exact numeric assertions, test edge cases (NULLs, empty results, large values), and use real fixture files from external formats. These would catch real regressions.
@nicosuave nicosuave force-pushed the nicosuave/find-untested-code branch from 76f18bd to dc9b291 Compare January 3, 2026 21:14
@nicosuave nicosuave merged commit 18b945f into main Jan 3, 2026
10 checks passed
@nicosuave nicosuave deleted the nicosuave/find-untested-code branch January 3, 2026 21:35
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.

1 participant