Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Date Functions to support week as a unit #16402

Open
Shanmugavel-J opened this issue Sep 5, 2024 · 4 comments
Open

Feature: Date Functions to support week as a unit #16402

Shanmugavel-J opened this issue Sep 5, 2024 · 4 comments
Assignees
Labels
C-feature Category: feature good first issue Category: good first issue

Comments

@Shanmugavel-J
Copy link

Summary

Not able to perform Date operations with unit week. Can it be added as a additional support for week.

QUERY: SELECT DATE_ADD('week', 1, TODAY());

SQL Error [1008]: Query failed (#7068da3e-54f5-4c3f-8c3d-4e9c0d2b99bc): error: 
  --> SQL:1:8
  |
1 | SELECT DATE_ADD('week', 1, TODAY())
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `add_weeks` does not exist
Copy link

dosubot bot commented Sep 5, 2024

Databend currently supports adding and subtracting various time units such as years, months, days, hours, minutes, and seconds, but it appears that the week unit is not yet supported for the DATE_ADD function [1][2].

To add support for the week unit, you would need to follow these steps:

  1. Implement the Function:

    • Add the logic for handling the week unit in the relevant function, such as date_add or add_weeks.
  2. Register the Function:

    • Register the new function in the register_add_functions method in src/query/functions/src/scalars/datetime.rs.
  3. Add Tests:

    • Add unit tests for the new functionality in src/query/functions/tests/it/scalars/datetime.rs.
  4. Update Documentation:

    • Ensure that the new functionality is documented appropriately.

For detailed guidance on writing and registering new functions, you can refer to the following guides:

This process will ensure that the week unit is supported in date operations like DATE_ADD.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the C-feature Category: feature label Sep 5, 2024
@TCeason
Copy link
Collaborator

TCeason commented Sep 5, 2024

Maybe you can try:

root@localhost:8000/default> SELECT DATE_ADD('day', 7, TODAY());

SELECT
  DATE_ADD('day', 7, TODAY())

-[ RECORD 1 ]-----------------------------------
DATE_ADD(DAY, 7, today()): 2024-09-12

And I think it's a good first issue.

@TCeason TCeason added the good first issue Category: good first issue label Sep 5, 2024
@Shanmugavel-J
Copy link
Author

Shanmugavel-J commented Sep 5, 2024

Yes @TCeason This would be a good addition for DATE functionality to ADD ON. Thanks!

It is good to have week as an unit. multiplication of 7 would be required.

@TracyZYJ
Copy link
Contributor

TracyZYJ commented Sep 9, 2024

Please assign me 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature good first issue Category: good first issue
Projects
None yet
Development

No branches or pull requests

3 participants