DATE_ADD/DATE_SUB with a single argument raises AttributeError (BigQuery, MySQL, Doris, StarRocks)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Start at build_date_delta_with_interval in the dialect module, which returns None when fewer than two args are passed, then follow it into Parser.validate_expression in parser.py where the None is dereferenced. Reproduce with sqlglot.parse_one("SELECT DATE_ADD(x)", read="bigquery") and compare against the DuckDB path that already raises a clean ParseError. Done means every listed dialect registration raises ParseError instead of AttributeError, with a test per dialect in the corresponding tests/dialects suite. Note an open pull request (#9105) already targets this, so coordinate before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Fully reproducible code snippet
import sqlglot
sqlglot.parse_one("SELECT DATE_ADD(x)", read="bigquery")
# AttributeError: 'NoneType' object has no attribute 'error_messages'
The same applies to DATE_SUB, DATETIME_ADD/SUB, TIME_ADD/SUB and TIMESTAMP_ADD/SUB in BigQuery, DATE_ADD/DATE_SUB in MySQL, and the Doris/StarRocks registrations of the same builder.
Expected
A ParseError. The same input in DuckDB raises a clean ParseError; BigQuery DATE_DIFF(x) raises ParseError; and BigQuery DATE_SUB(x, 1) raises "ParseError: INTERVAL expression expected but got '1'".
Actual
The dialect builder build_date_delta_with_interval returns None when len(args) < 2, and Parser.validate_expression then dereferences None.error_messages (in parser.py), producing the AttributeError.
Checked against main at commit b294f7f.
Official Documentation
BigQuery DATE_ADD requires a date expression and an INTERVAL: https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_add
MySQL DATE_ADD: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
Found by property-based testing (a no-crash property over mutated inputs drawn from sqlglot's own test corpus).
- Ngôn ngữ chính
- Python
- Star
- 9.8k
- Fork
- 1.4k
- Merge trung bình
- 13 giờ 19 phút
- Pull request đã merge (30 ngày)
- 243
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 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
SQLite: CAST(x AS JSON) is generated verbatim, which SQLite evaluates as a numeric castCó thể đã có người làm @Gowthamsuryagolla đã nhận hôm nay. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 32/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Optimizer drops parentheses for `NOT (<date> = DATE_TRUNC(...))`, changing query resultsCó thể đã có người làm @parthdembla007 đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/100
Maintainer thường phản hồi trong vòng 1 ngày
-
BigQuery: region-qualified INFORMATION_SCHEMA reference is rewritten across transpile passes, gaining an invented aliasCó thể đã có người làm @ansh-rohilla đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/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 75/100
alltheplaces/alltheplaces#20570 · 2 bình luận ·
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 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:ci bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
catincloud-labs/dagster-dex#206 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
number_to_words raises ValueError with threshold= for ordinals ("12th") and comma-grouped strings ("1,000")Có thể đã có người làm @hemtilva đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
providers security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
agentbreeder/agentbreeder#1031 ·
Maintainer thường phản hồi trong vòng 1 ngày