ClickHouse: DAY_OF_WEEK is read as DayOfWeek, so every call is written back as toDayOfWeek(t, 3)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design, databases
Direzione di ricerca
Start by tracing how the ClickHouse parser maps DAY_OF_WEEK and how DayOfWeek stores its arguments; compare that path with the correctly round-tripping DAYOFWEEK spelling. Run the reproductions in the issue and inspect the related ClickHouse parsing and generation tests. Done when calls with no mode and with modes 1, 2, or 3 round-trip with their documented results preserved.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
ClickHouse documents DAY_OF_WEEK as an alias of toDayOfWeek, like dayOfWeek and DAYOFWEEK. SQLGlot reads DAY_OF_WEEK as DayOfWeek (Sunday = 1) instead, so every call, with or without a mode, is written back as mode 3:
import sqlglot
for sql in ["SELECT DAY_OF_WEEK(t)", "SELECT DAY_OF_WEEK(t, 1)", "SELECT DAY_OF_WEEK(t, 2)"]:
print(sqlglot.transpile(sql, read="clickhouse", write="clickhouse")[0])
# SELECT toDayOfWeek(t, 3)
# SELECT toDayOfWeek(t, 3)
# SELECT toDayOfWeek(t, 3)
The other spellings round-trip correctly:
sqlglot.transpile("SELECT DAYOFWEEK(t)", read="clickhouse", write="clickhouse")
# ['SELECT toDayOfWeek(t)']
sqlglot.transpile("SELECT DAYOFWEEK(t, 2)", read="clickhouse", write="clickhouse")
# ['SELECT toDayOfWeek(t, 2)']
Expected: DAY_OF_WEEK(t) reads like toDayOfWeek(t) (mode 0, Monday = 1 … Sunday = 7), and DAY_OF_WEEK(t, mode) keeps its mode. The mode changes the numbering: 0 Monday = 1 … 7, 1 Monday = 0 … 6, 2 Sunday = 0 … 6, 3 Sunday = 1 … 7. So the rewrite to mode 3 changes the result of DAY_OF_WEEK(t) on every day of the week.
DayOfWeek holds this and zero_based, so a two-argument call passes the arity check and the mode is dropped silently.
Docs: https://clickhouse.com/docs/reference/functions/regular-functions/date-time-functions (toDayOfWeek: "Aliases: DAYOFWEEK, DAY_OF_WEEK", and its mode table).
Checked on 30.37.0. I used an LLM (Claude) to help narrow this down and write it up.
- Lingua principale
- Python
- Stelle
- 9.8k
- Fork
- 1.5k
- Merge medio
- 10h 54m
- PR unite (30g)
- 310
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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 tobymao/sqlglot
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
ClickHouse: quantile is read as the exact Quantile, though ClickHouse's quantile is approximateAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Oracle: qualify quotes USER, UID, ORA_ROWSCN and CONNECT_BY_ISLEAF/ISCYCLE as if they were columnsForse già presa @georgesittas l’ha presa oggi. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
tobymao/sqlglot#9468 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
INTERVAL '1 day ago' loses "ago" and becomes a positive intervalForse già presa @treysp l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di tobymao/sqlglot
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
litestar-org/sqlspec#946 ·
I maintainer di solito rispondono entro 1 giorno
-
area:cli area:docs Platform vdr
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA-NeMo/Gym#7192 ·
I maintainer di solito rispondono entro 2 giorni
-
Bug: CaseInsensitiveDict (event.headers) returns True for both == and != against the same mappingApertabug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws-powertools/powertools-lambda-python#8948 ·
I maintainer di solito rispondono entro 1 giorno
-
SofyaBotAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
ai-robots-txt/ai.robots.txt#324 ·
-
[Resource]: DashbarApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
hesreallyhim/awesome-claude-code#3821 · 1 commento ·