Fix dialect names, add CI, Oracle reads, and a control arm for the fold - #1
Merged
Conversation
Everywhere but sqlglot, MSSQL is called mssql here — read/mssql.py, the --mssql flag, the note in dialect_for_live. sqlglot only knows tsql, so --dialect mssql, the most natural thing to type, died inside the library with "Unknown dialect 'mssql'. Did you mean mysql?". normalize_dialect maps the aliases and rejects an unknown name as a domain error that lists what is available. It runs in expand() and in the engine's constructor rather than at the call sites, since the engine parses on its own path too and normalising in only one of them would let the two drift onto different dialects.
There were 388 tests and nothing that ran them on a push. requires-python says >=3.11, so the matrix covers the floor as well as the version in .python-version — a floor nobody runs is a guess. Verified both rows locally with uv run --isolated before wiring them up.
The read layer had DDL, SQL Server and Postgres, so an Oracle source could only arrive as a dumped DDL file. Adds an introspector on the same contract as the other two — catalog rows in, one PhysicalSchema out, no inference. Two Oracle facts shape the assembly. The owner is the schema and it is stored upper case, so a lower-case name returns zero rows and the database looks empty rather than misconfigured; the introspector upper-cases and falls back to CURRENT_SCHEMA when none is given, since Oracle has no fixed default the way Postgres has public. And num_rows is a statistics value that is NULL until someone gathers stats, which stays None instead of becoming 0 — a 0 would tell classify the table is empty and cost it the size weight it should have won. --dsn dispatches on an oracle:// prefix rather than gaining a sibling option, because six commands take --dsn and a second option would need the both-given check repeated in all six.
Everything in report/ measures the fold itself — how much it compressed, what survived, what stays answerable — and the goldset script measures tablefold against ground truth. None of it answers the claim the project actually makes, that Text-to-SQL fails on schema context rather than on the model. That claim needs the same questions asked without the fold. report/baseline.py is that arm: raw DDL in the prompt, physical SQL out, no expansion. It shares the completer, the questions, the execution check and the retry cap with the folded arm, so the one thing that differs is the shape the schema arrives in — a folded-only self-correction loop would leave it unclear whether the fold or the retries won. Not an identity layer, though that would be far less code. _reject_multiple_models refuses a query that reads two models, which is the guard that protects wide models; under one-model-per-table every join question dies on it, and most of the goldset needs a join. That scores the control at zero by tying its hands rather than by folding well. schema_ddl also replaces demo's own renderer, which drew no foreign keys and no comments. A baseline reading that version cannot know the join paths, which is the same rigging in a quieter form. Running the comparison needs the live MSSQL and LLM credentials, so the numbers are not in this commit — the harness is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
네 가지를 다룬다. 앞의 셋은 좁고, 마지막 하나가 본론이다.
1.
--dialect mssql이 터지던 것 (43d6553)sqlglot 이 아는 이름은
tsql뿐인데, 이 저장소는 다른 데서 전부 mssql 이라고 부른다 —read/mssql.py,--mssql플래그,dialect_for_live의 주석까지. 그래서 가장 자연스러운 입력이 라이브러리 깊은 곳에서 죽었다:normalize_dialect가 별칭을 받고, 모르는 이름은 쓸 수 있는 목록과 함께 도메인 오류로 세운다. 호출 지점이 아니라expand()와 엔진 생성자에 넣었다 — 엔진은 자체 파싱 경로를 따로 갖고 있어서, 한쪽만 정규화하면 두 경로가 서로 다른 방언으로 갈라진다.2. CI (
30e6d56)테스트가 388개 있었고 푸시 때 도는 것은 없었다.
requires-python이>=3.11이므로 하한도 매트릭스에 넣었다 — 아무도 안 돌리는 하한은 하한이 아니라 짐작이다. 두 줄 다uv run --isolated로 미리 돌려 보고 넣었다.3. Oracle 카탈로그 (
d2e0bdd)read 계층에 DDL·SQL Server·Postgres 는 있는데 Oracle 은 덤프 파일로만 들어올 수 있었다. 같은 계약을 지키는 탐색기를 붙인다.
Oracle 특유의 두 가지가 조립에 영향을 준다.
CURRENT_SCHEMA로 떨어진다 — Oracle 에는public같은 고정 기본값이 없다.num_rows는 통계값이라 수집 전에는NULL이다. 0 으로 채우면classify가 빈 테이블로 보고 크기 가중치를 깎는다.None으로 둔다.--dsn은 형제 옵션을 늘리는 대신oracle://접두사로 가른다.--dsn을 받는 명령이 여섯 개라, 옵션을 늘리면 "둘 다 준 경우" 검사도 여섯 군데가 된다.4. 접기의 대조군 (
e369dee) ← 본론report/의 나머지는 전부 접기 자체를 잰다 — 얼마나 줄었고, 무엇이 남았고, 무엇을 답할 수 있는지. 골드셋 스크립트는 tablefold 를 정답과 견준다. 그런데 이 프로젝트가 실제로 하는 주장은 "Text-to-SQL 이 실패하는 원인은 모델이 아니라 스키마 컨텍스트" 이고, 그 주장은 접지 않았을 때의 같은 숫자가 있어야 증명된다. 압축률은 접기가 무엇을 했는지 말하지, 그게 도움이 됐는지는 말하지 않는다.report/baseline.py가 그 반대편이다. 프롬프트에 원본 DDL 을 넣고 물리 SQL 을 직접 쓰게 하며, 확장 단계를 지나친다. completer·질문·실행 검증·재시도 상한을 접힌 팔과 공유하므로 달라지는 것은 스키마가 도착하는 모양 하나다 — 접힌 쪽만 자기수정을 가지면 이긴 원인이 접기인지 재시도인지 갈리지 않는다.항등 레이어가 아닌 이유. 표 하나를 모델 하나로 만들면 코드가 훨씬 적어진다. 그런데
_reject_multiple_models가 한 질의의 다중 모델 참조를 거부한다 — 와이드 모델을 지키려고 있는 가드다. 항등 레이어에서는 모든 조인 질문이 거기 걸려 죽고 골드셋 대부분이 조인을 필요로 하므로, 대조군이 0 점을 받는다. 접기가 잘해서가 아니라 대조군의 손발을 묶어서 이기는 실험이 된다.schema_ddl은 demo 의 기존 렌더러도 대체한다. 그쪽은 외래 키와 주석을 그리지 않았는데, 그걸 읽는 대조군은 조인 경로를 알 수 없다 — 같은 조작의 조용한 버전이다.숫자는 이 PR 에 없다. 실행에 라이브 MSSQL 과 LLM 자격 증명이 필요하다. 들어 있는 것은 하네스다:
값 일치율 두 개와, 한쪽만 맞힌 문항 목록이 나온다. 그 목록이 "접기가 정확히 무엇을 해결했는가" 의 답이다.
검증
ruff check/ruff format --check통과범위 밖으로 둔 것
demo/는 한 번도 lint 된 적이 없고main에도 ruff 오류 6 건이 있다(E501 5 +Any미임포트 1 —from __future__ import annotations가 있어 런타임 문제는 아니다). CI 범위를 조용히 넓히지 않고src tests로 뒀다. 따로 정리할 문제다.