Skip to content

Commit

Permalink
Added few functions to compare date and datetimes to fix some test ca…
Browse files Browse the repository at this point in the history
…ses in 'operator.date' test (AOS-203)

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
  • Loading branch information
Yury-Fridlyand committed Nov 19, 2021
1 parent dd357bc commit d62d23f
Showing 1 changed file with 73 additions and 2 deletions.
75 changes: 73 additions & 2 deletions sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,87 @@
<argument type='datetime' />
<argument type='datetime' />
</function>

<function group='operator' name='==' return-type='bool'>
<formula>(TIMESTAMP(%1) = TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='==' return-type='bool'>
<formula>(TIMESTAMP(%1) = TIMESTAMP(%2))</formula>
<argument type='datetime' />
<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) &lt;&gt; %2)</formula>
<formula>(TIMESTAMP(%1) &lt;&gt; TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='!=' return-type='bool'>
<formula>(%1 &lt;&gt; CAST(DATE_FORMAT(DATE(%2), '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula>
<formula>(TIMESTAMP(%1) &lt;&gt; TIMESTAMP(%2))</formula>
<argument type='datetime' />
<argument type='date' />
</function>
<function group='operator' name='&gt;=' return-type='bool'>
<formula>(TIMESTAMP(%1) &gt;= TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&gt;=' return-type='bool'>
<formula>(TIMESTAMP(%1) &gt;= TIMESTAMP(%2))</formula>
<argument type='datetime' />
<argument type='date' />
</function>
<function group='operator' name='&lt;=' return-type='bool'>
<formula>(TIMESTAMP(%1) &lt;= TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&lt;=' return-type='bool'>
<formula>(TIMESTAMP(%1) &lt;= TIMESTAMP(%2))</formula>
<argument type='datetime' />
<argument type='date' />
</function>
<function group='operator' name='&gt;' return-type='bool'>
<formula>(TIMESTAMP(%1) &gt; TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&gt;' return-type='bool'>
<formula>(TIMESTAMP(%1) &gt; TIMESTAMP(%2))</formula>
<argument type='datetime' />
<argument type='date' />
</function>
<function group='operator' name='&lt;' return-type='bool'>
<formula>(TIMESTAMP(%1) &lt; TIMESTAMP(%2))</formula>
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&lt;' return-type='bool'>
<formula>(TIMESTAMP(%1) &lt; TIMESTAMP(%2))</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(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0))</formula>
<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(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 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(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 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>
Expand Down

0 comments on commit d62d23f

Please sign in to comment.