ClickHouse: DAY_OF_WEEK is read as DayOfWeek, so every call is written back as toDayOfWeek(t, 3)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 9.8k
- Fork
- 1.5k
- Merge trung bình
- 10 giờ 54 phút
- Pull request đã merge (30 ngày)
- 310
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tobymao/sqlglot
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ClickHouse: quantile is read as the exact Quantile, though ClickHouse's quantile is approximateĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Oracle: qualify quotes USER, UID, ORA_ROWSCN and CONNECT_BY_ISLEAF/ISCYCLE as if they were columnsCó thể đã có người làm @georgesittas đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
tobymao/sqlglot#9468 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
INTERVAL '1 day ago' loses "ago" and becomes a positive intervalCó thể đã có người làm @treysp đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của tobymao/sqlglot
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
nael5x/creative-ai#130 ·
-
Make the "%" unit spacing the same in the web and in A10Có thể đã có người làm @kragent66-glitch đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 bình luận ·
-
ci severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TMHSDigital/Spackle#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pkg:lgm type:chore upstream-gaussx
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jejjohnson/pyrox#610 ·
Maintainer thường phản hồi trong vòng 1 ngày