repowisetobymao/sqlglot

tobymao / sqlglot

pythonmaind375836125.2K linessynced on Oct 26, 2026

Code health

4.1out of 10Needs work

Hotspots average 2.4, the place fixes pay off most.

Explore this codebase

Do next · 9

9 things worth doing in the week to Oct 26, the last indexed commit, 1 of them now.

Now

  • High

    Start breaking up __hash__ (CCN 24, 36 lines): first lift lines 864-885

    sqlglot/expressions/core.py:864

    __hash__ nests deeply; easier to read and change once split; function changed in 4 commits; its file is imported by 20 files, changed 9 times in 90 days.

    gain
    +0.5 health on this file(inferred)
    health recoverable
    +0.5(inferred)
    size
    CCN 24, 36 lines, nests 8 deep
    steps
    3 (3 mechanical)

Worth planning

  • Tidy the code shape this week's commits left: 16 findings in 7 files

    11 commits in the last 7 days added or worsened long, complex or deeply nested code, still open. Start with sqlglot/optimizer/unnest_subqueries.py (4 findings): tidying it while the change is fresh costs less than after the next one.

    code-shape findings
    16
    files
    7
    commits
    11
  • Start breaking up to_node (CCN 77, 235 lines): first lift lines 358-368

    sqlglot/lineage.py:358

    to_node has many paths; easier to read and change once split, which also removes a duplicate; function changed in 27 commits; its file is imported by 1 file, changed 3 times in 90 days.

    gain
    up to +0.4 health on this file(inferred)
    finding
    Complex method
    size
    CCN 77, 235 lines, nests 5 deep
    severity
    high
    worth a check
  • Start breaking up canonicalize_internal_names (CCN 90, 211 lines)

    sqlglot/optimizer/canonicalize_internal_names.py:262

    canonicalize_internal_names has many paths; easier to read and change once split; function changed in 10 commits; its file is imported by 1 file, changed 5 times in 90 days.

    gain
    up to +2.6 health on this file(inferred)
    finding
    Complex method
    size
    CCN 90, 211 lines, nests 8 deep
    severity
    high
    worth a check
  • Simplify _parse_types in sqlglot/parser.py: tests reach it, and fixes keep landing

    Changed 93 times in 90 days, and 51 of those commits were bug fixes.

    commits in 90 days
    93
    bug-fix commits
    51
    line coverage
    Unknown, no report
    tests that reach it
    4 test files, call graph(inferred)
    worth a check

Everything we found

5 areas