Document string literals in single-part INTERVAL constructors
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
[`docs/lexical.md`](https://github.com/google/googlesql/blob/f52731d52c4d5b67eff3c7649520f8569ab3c658/docs/lexical.md#L1047) and [`docs/data-types.md`](https://github.com/google/googlesql/blob/f52731d52c4d5b67eff3c7649520f8569ab3c658/docs/data-types.md#L1298) describe the single-part form only as:
```sql
INTERVAL int64_expression datetime_part
```
However, the implementation also supports string literals without `TO`:
```sql
SELECT INTERVAL '1' DAY
```
At GoogleSQL 2026.9.1(f52731d52c4d5b67eff3c7649520f8569ab3c658):
- [`googlesql.tm`](https://github.com/google/googlesql/blob/f52731d52c4d5b67eff3c7649520f8569ab3c658/googlesql/parser/googlesql.tm#L10674) accepts an expression followed by a single datetime part.
- [`ResolveIntervalExpr`](https://github.com/google/googlesql/blob/f52731d52c4d5b67eff3c7649520f8569ab3c658/googlesql/analyzer/resolver_expr.cc#L12952) explicitly handles string literals and, without an ending part, calls the single-part `IntervalValue::ParseFromString` overload. This is interval-specific parsing, not implicit `STRING`-to-`INT64` coercion.
- An [existing analyzer test](https://github.com/google/googlesql/blob/f52731d52c4d5b67eff3c7649520f8569ab3c658/googlesql/analyzer/testdata/interval.test#L713) resolves `INTERVAL '7' DAY` to a seven-day interval.
Please document the string-literal alternative in both sections and add an example such as `INTERVAL '1' DAY`. This requests documentation of existing behavior, not acceptance of arbitrary `STRING` expressions or a parser change.
Contributor guide
Research direction
Start with the single-part INTERVAL sections in docs/lexical.md and docs/data-types.md, then review googlesql/analyzer/testdata/interval.test around the existing INTERVAL '7' DAY case. Document string literals as an accepted alternative and add an example such as INTERVAL '1' DAY in both sections. Confirm the existing analyzer test still covers the documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100