moshap-firebolt opened a new pull request, #2614:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2614

   Spark's [multi-units interval 
syntax](https://spark.apache.org/docs/latest/sql-ref-literals.html#interval-literal)
 lets the string carry its own units, so no unit follows the literal:
   
   ```sql
   SELECT INTERVAL '1 YEAR 2 DAYS 3 HOURS';
   SELECT INTERVAL '2 seconds' * 2;
   ```
   
   Both `SparkSqlDialect` and `DatabricksDialect` set 
`require_interval_qualifier`, so these fail with `INTERVAL requires a unit 
after the literal value`. Databricks Runtime parses with Spark's grammar and 
accepts them too; the [Databricks 
docs](https://docs.databricks.com/aws/en/sql/language-manual/data-types/interval-type)
 show only the qualified form.
   
   This sets `require_interval_qualifier` to `false` for both dialects. A unit 
after a literal is still parsed, so `INTERVAL '1' DAY`, `INTERVAL 12 HOURS` and 
`INTERVAL '1-2' YEAR TO MONTH` are unchanged. The form this gives up is an 
expression as the interval value (`INTERVAL 1 + 1 DAY`), which Spark's grammar 
does not allow: it takes a literal there.
   
   Tests cover the string forms, the qualified forms, signs and arithmetic for 
both dialects.
   
   Note: `parse_tuple_element_access` fails on current `main` (14cbf755) as 
well, independent of this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to