From bbf988bd73b00d18dd1d443f225b3915a2c4433f Mon Sep 17 00:00:00 2001 From: Max Gekk Date: Wed, 11 Aug 2021 13:38:39 +0300 Subject: [PATCH] [SPARK-36468][SQL][DOCS] Update docs about ANSI interval literals ### What changes were proposed in this pull request? In the PR, I propose to update the doc page https://spark.apache.org/docs/latest/sql-ref-literals.html#interval-literal, and describe formats of ANSI interval literals. Screenshot 2021-08-11 at 10 31 36 Screenshot 2021-08-10 at 20 58 04 ### Why are the changes needed? To improve UX with Spark SQL, and inform users about recently added ANSI interval literals. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Manually checked the generated docs: ``` $ SKIP_API=1 SKIP_RDOC=1 SKIP_PYTHONDOC=1 SKIP_SCALADOC=1 bundle exec jekyll build ``` Closes #33693 from MaxGekk/doc-ansi-interval-literals. Authored-by: Max Gekk Signed-off-by: Max Gekk --- docs/sql-ref-literals.md | 91 ++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 21 deletions(-) diff --git a/docs/sql-ref-literals.md b/docs/sql-ref-literals.md index b23c63a98e..355ac69cef 100644 --- a/docs/sql-ref-literals.md +++ b/docs/sql-ref-literals.md @@ -439,13 +439,78 @@ SELECT TIMESTAMP '1997-01' AS col; An interval literal is used to specify a fixed period of time. +#### ANSI style + +The ANSI SQL standard defines interval literals in the form: +```sql +INTERVAL [ ] +``` +where `` can be a single field or in the field-to-field form: +```sql + ::= TO | +``` +The field name is case-insensitive, and can be one of `YEAR`, `MONTH`, `DAY`, `HOUR`, `MINUTE` and `SECOND`. + +An interval literal can have either year-month or day-time interval type. The interval sub-type defines format of ``: +```sql + ::= [ ] { | } + ::= [ ] | + ::= |