You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "uros-db (via GitHub)" <gi...@apache.org> on 2025/07/20 13:41:35 UTC
[PR] [WIP][SPARK-52898][SQL] Support TIME addition [spark]
uros-db opened a new pull request, #51580:
URL: https://github.com/apache/spark/pull/51580
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
In the PR, I propose to support the `+` operator over two TIME columns.
Syntax
```
expr1 + expr2
```
Arguments
- `expr1`: A TIME expression.
- `expr2`: A TIME expression.
Returns
- The result is an INTERVAL HOUR TO SECOND
Examples
```
> SELECT '12:30:41.123' + TIME'10:00:01';
0 22:30:42.123000000
> SELECT typeof(TIME'16:00:10' + TIME'08:30:20');
interval hour to second
```
### Why are the changes needed?
To conform the ANSI SQL standard.
### Does this PR introduce _any_ user-facing change?
Yes, this PR introduces new operator support for TIME.
### How was this patch tested?
New tests added.
```
$ build/sbt "test:testOnly *DateTimeUtilsSuite"
$ build/sbt "test:testOnly *TimeExpressionsSuite"
$ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z time.sql"
```
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52898][SQL] Support TIME addition [spark]
Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on PR #51580:
URL: https://github.com/apache/spark/pull/51580#issuecomment-3095214254
> > To conform the ANSI SQL standard.
>
> Could you point me out where the SQL standard defines such operation. So far I haven't found it: <img alt="Screenshot 2025-07-20 at 17 42 07" width="821" height="432" src="https://private-user-images.githubusercontent.com/1580697/468394721-4cb45493-2961-4c9d-a473-7852e1b78b89.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTMwNzM5OTMsIm5iZiI6MTc1MzA3MzY5MywicGF0aCI6Ii8xNTgwNjk3LzQ2ODM5NDcyMS00Y2I0NTQ5My0yOTYxLTRjOWQtYTQ3My03ODUyZTFiNzhiODkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDcyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA3MjFUMDQ1NDUzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDFiMmNiY2VmZTgxMzQ3OTM0NTFlOTQ2MjRlNjg3Mjg4NGEyMDQ1MDRhMzFiOGM4YmUxNjNhZjE4MTU2ZDRiZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.okOTIG9PWlU3PMrr0l7iiD9RMyjmIWcKQYHEm-fzseY">
>
> What is the meaning of the operation in term of use cases? Also cc @srielau
Yes, subtraction of time makes sense, as defined in the standard. Addition does not.
The standard did not "forget" plus.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52898][SQL] Support TIME addition [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #51580:
URL: https://github.com/apache/spark/pull/51580#issuecomment-3094623162
@uros-db What is the physical meaning of adding one time value to another?
```
TIME '12:30:41.123' + TIME'10:00:01'
```
It doesn't make any sense? The same as you would add dates:
```
DATE'2025-07-20' + DATE'2025-07-21'
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52898][SQL] Support TIME addition [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on PR #51580:
URL: https://github.com/apache/spark/pull/51580#issuecomment-3094617110
This PR, and the corresponding requirements / SQL ref spec for TIME type, should be very similar to https://github.com/apache/spark/pull/51441 (the `-` operator). @MaxGekk
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52898][SQL] Support TIME addition [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db commented on PR #51580:
URL: https://github.com/apache/spark/pull/51580#issuecomment-3095559353
Ack @srielau, thank you for the clarification. I'm closing this PR, cc @MaxGekk.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-52898][SQL] Support TIME addition [spark]
Posted by "uros-db (via GitHub)" <gi...@apache.org>.
uros-db closed pull request #51580: [SPARK-52898][SQL] Support TIME addition
URL: https://github.com/apache/spark/pull/51580
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org