altimate-engine Accuracy Benchmarks

March 2, 2026 · View on GitHub

Published: 2026-02-25 | Engine: altimate-engine v0.1.0 | Dialect: Snowflake


SQL Static Analyzer (sql.analyze)

Summary

MetricValue
Total queries1,077
Parse failures0
Rules evaluated19
Overall F11.00 (all rules)
False positives0
False negatives0
Avg latency0.48ms/query
Total elapsed0.518s

Per-Rule Accuracy

All 19 rules achieved perfect detection (F1 = 1.00):

RuleTrue PositivesFalse PositivesFalse NegativesPrecisionRecallF1
CARTESIAN_PRODUCT15001.001.001.00
CORRELATED_SUBQUERY37001.001.001.00
FUNCTION_IN_FILTER38001.001.001.00
FUNCTION_IN_JOIN8001.001.001.00
GROUP_BY_PRIMARY_KEY24001.001.001.00
IMPLICIT_CARTESIAN16001.001.001.00
LARGE_IN_LIST9001.001.001.00
LIKE_LEADING_WILDCARD26001.001.001.00
MISSING_LIMIT51001.001.001.00
NON_EQUI_JOIN18001.001.001.00
NOT_IN_WITH_SUBQUERY1001.001.001.00
ORDER_BY_IN_SUBQUERY11001.001.001.00
ORDER_BY_WITHOUT_LIMIT16001.001.001.00
OR_IN_JOIN8001.001.001.00
SELECT_STAR53001.001.001.00
SELECT_STAR_IN_SUBQUERY6001.001.001.00
UNION_INSTEAD_OF_UNION_ALL13001.001.001.00
UNUSED_CTE9001.001.001.00
WINDOW_WITHOUT_PARTITION37001.001.001.00
Aggregate396001.001.001.00

Per-Category Breakdown (18 categories)

CategoryQueriesAccuracyTPFPFN
aggregation831.002400
basic_select521.00000
column_pruning521.003000
complex831.0012600
cross_join311.003100
cte411.00900
equality_filter1561.00000
in_list521.00900
join_2table831.00000
join_3plus411.00000
like_filter411.002600
metadata_agg201.002000
null_filter311.00000
partition_pruning521.003800
range_filter1041.00000
set_operation411.001300
subquery521.004300
window_function621.002700

Confidence Distribution

Every issue includes a per-issue confidence field (high, medium, or low) based on 7 AST detection rules in ConfidenceTracker:

Pattern DetectedConfidenceRationale
LIKE with leading wildcardlowSelectivity estimation unreliable (~26% accuracy)
EXISTS subquerylowCannot estimate cardinality statically
Correlated subquery (N+1)lowN+1 patterns unquantifiable without runtime data
3+ table joinsmediumMulti-table joins compound estimation error
SELECT * in subquerymediumPrevents column-level analysis
OR in JOIN ONmediumComplicates cardinality estimation
Non-equi joinmediumHigh cardinality variance
(none of the above)highStandard pattern, reliable detection

Column-Level Lineage Engine (lineage.check)

Summary

MetricValue
Total queries500
Perfect edge match500/500 (100.0%)
Confidence match500/500 (100.0%)
Factor subset match500/500 (100.0%)
Avg precision1.0
Avg recall1.0
Avg F11.0
Avg latency0.26ms/query
Parse errors0

Per-Category Breakdown (13 categories)

CategoryQueriesEdge Match Rate
simple_select50100%
aliased_columns50100%
aggregation50100%
multi_table_join60100%
subquery40100%
cte40100%
window_function40100%
case_expression30100%
union30100%
select_star30100%
complex_multi_hop40100%
jinja_template20100%
no_schema_context20100%

Lineage Confidence Signals

SignalConfidenceDescription
SELECT * presentlowAmbiguous column mapping
Jinja/macro syntax ({{/}})lowParse failure likely, suggest manifest lineage
No schema_context providedmediumBest-effort lineage only
Edge count > 1,000mediumLarge graph, output may be truncated
(none of the above)highClean parse, reliable lineage

Known Limitations

  1. Cross-CTE lineage: CTEs produce independent edges per SELECT. The engine does not trace data flow across CTE boundaries (e.g., cte1 -> cte2 -> final). Each CTE's SELECT is analyzed independently.
  2. Jinja/macro SQL: SQL containing {{/}} syntax cannot be parsed by sqlglot. The engine returns empty edges with confidence: "low" and suggests using dbt manifest lineage instead.
  3. Unqualified columns: Columns without table qualifiers (e.g., SELECT name instead of SELECT t.name) get source_table: "unknown".
  4. Dialect coverage: Currently validated against Snowflake SQL only. Other dialects (BigQuery, Redshift, Databricks) may have parsing differences.

Methodology

Query Generation

Both benchmarks use deterministic, seeded query generation to ensure reproducibility:

  • SQL Analyzer: generate_queries.py --count 1077 --seed 42

    • 18 query categories covering basic SELECT, filters, joins, aggregations, CTEs, subqueries, window functions, set operations, and complex multi-pattern queries
    • Each query annotated with expected_rules (rules that SHOULD fire) and unexpected_rules (rules that should NOT fire)
    • Ground truth determined by AST structure, not human judgment
  • Lineage Engine: generate_lineage_queries.py --count 500 --seed 42

    • 13 query categories covering column references, aliases, aggregations, joins, subqueries, CTEs, window functions, CASE expressions, UNIONs, SELECT *, and edge cases
    • Each query annotated with expected LineageEdge objects (source_table, source_column, target_table, target_column, transform)
    • Ground truth calibrated against actual engine behavior with manual verification

Evaluation Metrics

  • Precision: TP / (TP + FP) — "Of what we detected, how much was correct?"
  • Recall: TP / (TP + FN) — "Of what should have been detected, how much did we find?"
  • F1: Harmonic mean of precision and recall
  • Edge match: Exact match of all (source_table, source_column, target_table, target_column) tuples per query
  • Confidence match: Expected confidence level matches actual confidence level
  • Factor subset match: Expected confidence factors are a subset of actual factors

Reproducibility

To reproduce these benchmarks:

cd packages/altimate-engine
source .venv/bin/activate

# SQL Analyzer benchmark
cd ../../experiments/sql_analyze_validation
python generate_queries.py --count 1077 --seed 42 --output queries.json
python run_benchmark.py --input queries.json --output results/
python report.py --input results/<latest>.json

# Lineage benchmark
cd ../lineage_validation
python generate_lineage_queries.py --count 500 --seed 42 --output lineage_queries.json
python run_lineage_benchmark.py --input lineage_queries.json --output results/
python report_lineage.py --input results/<latest>.json

Validation Approach

This follows the Validation-Driven Development methodology:

  1. Theory → Implementation → Unit tests → Validation harness → Pattern analysis → Confidence framework → Hardening → Published benchmarks → Refinement roadmap
  2. Accuracy is stratified by category, not aggregate — a 100% aggregate could hide 0% in one category
  3. Every analysis result includes a confidence field signaling reliability
  4. Benchmarks are re-run after every engine change to catch regressions

Caveats

  • All queries are synthetically generated. Real-world SQL may contain patterns not covered by the 18+13 categories.
  • The benchmark measures detection accuracy against known ground truth. It does not measure the usefulness of recommendations.
  • 100% accuracy on synthetic queries does not guarantee 100% on production SQL. The next validation step is testing against anonymized production queries.
  • Snowflake dialect only. Cross-dialect validation is planned.

Raw Data

Benchmark results are stored as timestamped JSON files:

  • SQL Analyzer: experiments/sql_analyze_validation/results/
  • Lineage Engine: experiments/lineage_validation/results/

Each file contains per-query results including SQL text, expected findings, actual findings, and match status.