162f0560e6
### What changes were proposed in this pull request? 1. Add the SQL config `spark.sql.legacy.interval.enabled` which will control when Spark SQL should use `CalendarIntervalType` instead of ANSI intervals. 2. Modify the `SubtractDates` expression to return values of `DayTimeIntervalType` when `spark.sql.legacy.interval.enabled` is set to `false` (which is the default). ### Why are the changes needed? To conform to the ANSI SQL standard which requires ANSI intervals as the result of dates subtraction, see <img width="656" alt="Screenshot 2021-03-29 at 19 09 34" src="https://user-images.githubusercontent.com/1580697/112866455-7e2f0d00-90c2-11eb-96e6-3feb7eea7e09.png"> ### Does this PR introduce _any_ user-facing change? Yes. ### How was this patch tested? By running new tests: ``` $ build/sbt "test:testOnly *DateExpressionsSuite" $ build/sbt "test:testOnly *ColumnExpressionSuite" ``` and some tests from `SQLQueryTestSuite`: ``` $ build/sbt "sql/testOnly *SQLQueryTestSuite -- -z date.sql" $ build/sbt "sql/testOnly *SQLQueryTestSuite -- -z datetime.sql" $ build/sbt "sql/testOnly *SQLQueryTestSuite -- -z interval.sql" ``` Closes #31996 from MaxGekk/subtract-dates-to-intervals. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com> |
||
---|---|---|
.. | ||
src | ||
pom.xml |