OpenMLDB icon indicating copy to clipboard operation
OpenMLDB copied to clipboard

built-in-function: Support `last_day(TIMESTAMP)` function

Open jingchen2222 opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe.

last_day(date|timestamp|int64)

Returns the last day of the month to which the date belongs to.

Notices: We only need to support last_day(timestamp)

Examples:

> SELECT last_day(timestamp("2020-05-22 10:43:40"));
 2020-05-31
> SELECT last_day(timestamp("2020-02-12 10:43:40"));
 2020-02-29
> SELECT last_day(date("2020-02-12"));
 2020-02-29

Reference:

https://spark.apache.org/docs/latest/api/sql/#last_day Describe the solution you'd like

We do provide a built-in function development guide for you. Please check OpenMLDB Build-In Function Develop Guide or the Chinese version for help.

Please make sure you:

  • [ ] Add built-in C++ function in src/udf/udf.h and src/udf/udf.cc
  • [ ] Register function to default library from function void DefaultUdfLibrary::InitTimeAndDateUdf() in src/udf/default_udf_library.cc.
  • [ ] Add related unit test in src/codegen/udf_ir_builder_test.cc
  • [ ] Documenting function

If you have any questions or concerns, please let us know. We appreciate every piece of code, comment. Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

jingchen2222 avatar Dec 02 '21 00:12 jingchen2222

Hi, can you give me a chance to work on it? Many thanks

hezean avatar Jul 08 '22 19:07 hezean

Hi, can you give me a chance to work on it? Many thanks

Go ahead

aceforeverd avatar Jul 10 '22 07:07 aceforeverd