-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dialect fixes for operator.date test as of AOS-203 #4
Changes from 3 commits
d62d23f
96ac3ca
be77676
634d4e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,16 +63,87 @@ | |
<argument type='datetime' /> | ||
<argument type='datetime' /> | ||
</function> | ||
|
||
<function group='operator' name='==' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='==' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think just calling TIMESTAMP would cause an issue where the time would not be 00:00:00 as expected. We have to do something like SUBDATE(TIMESTAMP(DATE(%2)), INTERVAL HOUR(TIMESTAMP(DATE(%2))) HOUR). This will likely result in a an error logged in this issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='!=' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(DATE(%1), '%Y-%m-%d 00:00:00') AS TIMESTAMP) <> %2)</formula> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='!=' return-type='bool'> | ||
<formula>(%1 <> CAST(DATE_FORMAT(DATE(%2), '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='>=' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='>=' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='<=' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='<=' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='>' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='>' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='<' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='<' return-type='bool'> | ||
<formula>(CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
|
||
<function group='operator' name='-' return-type='real'> | ||
<!-- 86400 as it represents seconds in a day --> | ||
<formula>((TO_DAYS(CAST(%1 as TIMESTAMP)) - TO_DAYS(CAST(%2 as TIMESTAMP))) + ((TIME_TO_SEC(CAST(%1 as TIMESTAMP)) - TIME_TO_SEC(CAST(%2 as TIMESTAMP))) / 86400.0))</formula> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting DATE to TIMESTAMP doesn't work. We have to use TIMESTAMP() or DATE_FORMAT. Ideally we should use SUBDATE(TIMESTAMP(%2), INTERVAL HOUR(TIMESTAMP(%2)) HOUR). |
||
<argument type='date' /> | ||
<argument type='datetime' /> | ||
</function> | ||
<function group='operator' name='-' return-type='real'> | ||
<!-- 86400 as it represents seconds in a day --> | ||
<formula>((TO_DAYS(CAST(%1 as TIMESTAMP)) - TO_DAYS(CAST(%2 as TIMESTAMP))) + ((TIME_TO_SEC(CAST(%1 as TIMESTAMP)) - TIME_TO_SEC(CAST(%2 as TIMESTAMP))) / 86400.0))</formula> | ||
<argument type='datetime' /> | ||
<argument type='date' /> | ||
</function> | ||
<function group='operator' name='-' return-type='real'> | ||
<!-- 86400 as it represents seconds in a day --> | ||
<formula>((TO_DAYS(CAST(%1 as TIMESTAMP)) - TO_DAYS(CAST(%2 as TIMESTAMP))) + ((TIME_TO_SEC(CAST(%1 as TIMESTAMP)) - TIME_TO_SEC(CAST(%2 as TIMESTAMP))) / 86400.0))</formula> | ||
<argument type='datetime' /> | ||
<argument type='datetime' /> | ||
</function> | ||
|
||
<function group='operator' name='+' return-type='datetime'> | ||
<!-- 86400 as it represents seconds in a day --> | ||
<formula>DATE_ADD(DATE_ADD(%1, INTERVAL FLOOR(%2) DAY), INTERVAL CAST(86400 * (%2 - FLOOR(%2)) AS INT) SECOND)</formula> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an alternative here to just use the TIMESTAMP function directly instead of the combo CAST/DATE_FORMAT?