You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered that in MySQL some functions' return type depends on arguments' values (not on their types❗)
For example, DATE_ADD function returns
DATETIME when arguments are TIME and date or complexINTERVAL
DATETIME when arguments are DATE and time or complexINTERVAL
TIME when arguments are TIME and timeINTERVAL
DATE when arguments are DATE and dateINTERVAL
...
So function had following signature:
(DATE, INTERVAL) -> DATE
(DATE, INTERVAL) -> DATETIME
(TIME, INTERVAL) -> TIME
(TIME, INTERVAL) -> DATETIME
...
Which is extremely ambiguous for Resolver. It picked first matching signature (last in the list) and used it for further resolving.
In the given example (see pic), a signature which returns DATE was resolved, but actual function execution returned DATETIME.
What solution would you like?
Introduce 3 new INTERVAL-like types instead of existing INTERVAL (ExprIntervalValue):
DATE_INTERVAL which operates with date terms, like days, months and years
TIME_INTERVAL which operates with time terms, e.g. hours, minutes and so on
DATETIME_INTERVAL which all datetime terms
These types shouldn't be visible for user to avoid confusion. Syntax shouldn't be changed.
These types should support more than one term, e.g. 'x hours y seconds' and even 'x years y minutes' for DATETIME_INTERVAL. This feature should implement complex interval expressions.
This feature should contain update for DATE_ADD function (and its siblings: ADDDATE, SUBDATE, DATE_SUB) as a use case:
Yury-Fridlyand
changed the title
[FEATURE] Add 3 interval types instead of 1
[FEATURE] Add 3 interval types instead of 1 to support complex interval expressions
Oct 4, 2022
Is your feature request related to a problem?
I discovered that in MySQL some functions' return type depends on arguments' values (not on their types❗)
For example,
DATE_ADD
function returnsDATETIME
when arguments areTIME
and date or complexINTERVAL
DATETIME
when arguments areDATE
and time or complexINTERVAL
TIME
when arguments areTIME
and timeINTERVAL
DATE
when arguments areDATE
and dateINTERVAL
So function had following signature:
Which is extremely ambiguous for
Resolver
. It picked first matching signature (last in the list) and used it for further resolving.In the given example (see pic), a signature which returns
DATE
was resolved, but actual function execution returnedDATETIME
.What solution would you like?
Introduce 3 new
INTERVAL
-like types instead of existingINTERVAL
(ExprIntervalValue
):DATE_INTERVAL
which operates with date terms, like days, months and yearsTIME_INTERVAL
which operates with time terms, e.g. hours, minutes and so onDATETIME_INTERVAL
which all datetime termsDATETIME_INTERVAL
. This feature should implement complex interval expressions.DATE_ADD
function (and its siblings:ADDDATE
,SUBDATE
,DATE_SUB
) as a use case:What alternatives have you considered?
N/A
Do you have any additional context?
#855
The text was updated successfully, but these errors were encountered: