opensearch-project / opensearch-project/sql
[FEATURE] Add new data type: `PERIOD`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 176
- Forks
- 229
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
Description
Is your feature request related to a problem?
MySQL has no such type, at least visible to user, but having a such type we can simplify processing few datetime functions.
... number in YYMMDD, YYMMDDhhmmss, YYYYMMDD, or YYYYMMDDhhmmss format. If the argument includes a time part, it may optionally include a fractional seconds part.
See PERIOD_ADD/PERIOD_DIFF functions in MySQL docs for reference.
The proposed solution would help fixing NOW() + 0 issue, see discussion in #754 and https://github.com/Bit-Quill/opensearch-project-sql/pull/92.
What solution would you like?
A new data type PERIOD
- Responsible for parsing and formatting
- Couldn't be casted to numeric types
- Expose a numeric type for user
- Has operators
+and-overloaded with integers.
This will also simplify UNIX_TIMESTAMP implementation (#835) https://github.com/opensearch-project/sql/blob/e04d6f886aa57ee4fdd8e632127bb5d8a339113f/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java#L915-L938
Other functions affected: all listed in #754, EXTRACT, UTC_DATE, UTC_TIME and UTC_TIMESTAMP (link).
What alternatives have you considered?
Keep using numeric type.
Do you have any additional context?
#855
#722
#835
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java, especially the UNIX_TIMESTAMP implementation referenced in the issue. Read the linked MySQL PERIOD_ADD and PERIOD_DIFF documentation and review issues #754, #835, #855, and #722 for affected behavior. Done means a PERIOD type supports parsing and formatting, exposes a numeric value without numeric casts, and defines integer + and - operators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100