ClickHouse aggregate-alias rewrite changes column bindings inside scalar subqueries
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia in core/wren/src/wren/mdl/clickhouse_compat.py, leggi translate e il controllo di scope dell'aggregato esterno intorno alle righe 263–282, poi esegui lo script di riproduzione dell'issue. Il punto chiave è che agg.find_all(exp.Column) scende nei SELECT annidati, quindi la riscrittura deve fermarsi allo scope SELECT proprio dell'aggregato. Fatto significa che la c interna resta legata a u mentre l'alias dell'aggregato esterno viene ancora gestito; aggiungi o esegui un test di regressione per l'esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hullo folks,
I’m doing some research for Tessl Code Review and ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:
Describe the bug
The aggregate-alias compatibility rewrite descends into nested SELECTs. When an outer aggregate is aliased as c, it qualifies an unqualified c inside a scalar subquery with the outer table, even though that column belongs to the subquery's table.
This is a separate case from #2782: the alias fix introduced by #2783 is useful for the outer aggregate, but should not change a child SELECT's column binding.
To reproduce
With the current core/wren/src/wren/mdl/clickhouse_compat.py and SQLGlot 29.0.1:
from sqlglot import parse_one
from wren.mdl import clickhouse_compat
ast = parse_one(
"SELECT t.id, SUM((SELECT c FROM u WHERE u.id = t.id)) AS c "
"FROM t GROUP BY t.id"
)
print(ast.sql(dialect="clickhouse"))
clickhouse_compat.translate(ast)
print(ast.sql(dialect="clickhouse"))
Observed output from executing the current module directly:
-- Before
SELECT t.id, SUM((SELECT c FROM u WHERE u.id = t.id)) AS c FROM t GROUP BY t.id
-- After
SELECT t.id, SUM((SELECT t.c FROM u WHERE u.id = t.id)) AS c FROM t GROUP BY t.id
For tables t(id) and u(id, c), the generated t.c does not exist. If t also has a c column, this instead changes which value is aggregated.
Expected behavior
Preserve the inner c binding to u. The qualifier rewrite should only visit columns belonging to the aggregate's own SELECT scope. The current outer-aggregate scope check excludes nested aggregates, but its subsequent agg.find_all(exp.Column) still visits columns inside nested SELECTs.
Wren AI information and validation
Checked source 48de0b6cbd02cbbe3753f29e37f4be24e8a9a7fd (core/wren 0.18.0), Python 3.14.2, SQLGlot 29.0.1 on macOS arm64. The reproduction directly executes the current compatibility module and confirms the AST/output rewrite. It does not launch WrenEngine or a ClickHouse server.
The finding came from a retrospective review of merged PR #2783 and remains reproducible at this commit.
Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.
We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.
Bap
- Lingua principale
- Python
- Stelle
- 17.8k
- Fork
- 2k
- Merge medio
- 5g 5h
- PR unite (30g)
- 21
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Canner/WrenAI
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 4 giorni
-
The DuckDB connector cannot attach files named `memory.duckdb`, `main.duckdb` or `temp.duckdb`Forse già presa @anasdahani220 l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Canner/WrenAI#2875 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
The DuckDB MinIO connector signs every S3 request for `ap-northeast-1`Forse già presa @MohammadHijjawi97 l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 4 giorni
-
[BUG] Trino connector: relative verify CA path resolves against CWD, not a stable rootForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug stale
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Canner/WrenAI#2747 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di Canner/WrenAI
Issue simili
-
bug docs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
ActivityWatch/docs#223 ·
-
[Bug]: OpenCode v2 skips an assistant message that gains text after an earlier captureForse già presa @jianyx1 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
volcengine/OpenViking#8354 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ARTPARK-SAHAI-ORG/calibrate-frontend#842 ·
I maintainer di solito rispondono entro 1 giorno
-
comp/tools P2 tool/skills type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#159541 ·
I maintainer di solito rispondono entro 1 giorno