DATE_ADD/DATE_SUB with a single argument raises AttributeError (BigQuery, MySQL, Doris, StarRocks)

オープン
#9,103 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@akchhayasharma がすでに取り組んでいます。

2026年11月15日 から。

  • #9105 @akchhayasharma による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Python
スター
9.8k
フォーク
1.4k
平均マージ
13時間 19分
マージ済み PR(30日)
243

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tobymao/sqlglot のほかの issue

tobymao/sqlglot の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。