Skip to content
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

Add functions for date type in the TACO (#5) #91

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 75 additions & 2 deletions bi-connectors/TableauConnector/src/dialect.tdd
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='==' return-type='bool'>
<formula>(%1 = %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='!=' return-type='bool'>
<formula>(%1 AND NOT %2 OR NOT %1 AND %2)</formula>
<argument type='bool' />
Expand Down Expand Up @@ -127,6 +132,11 @@
<argument type='datetime' />
<argument type='date' />
</function>
<function group='operator' name='!=' return-type='bool'>
<formula>(%1 &lt;&gt; %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='&gt;' return-type='bool'>
<formula>(%1 &gt; CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula>
<argument type='datetime' />
Expand All @@ -137,6 +147,11 @@
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&gt;' return-type='bool'>
<formula>(%1 &gt; %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='&gt;=' return-type='bool'>
<formula>(%1 &gt;= CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula>
<argument type='datetime' />
Expand All @@ -147,6 +162,11 @@
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&gt;=' return-type='bool'>
<formula>(%1 &gt;= %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='&lt;' return-type='bool'>
<formula>(%1 &lt; CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula>
<argument type='datetime' />
Expand All @@ -157,6 +177,11 @@
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&lt;' return-type='bool'>
<formula>(%1 &lt; %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='&lt;=' return-type='bool'>
<formula>(%1 &lt;= CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))</formula>
<argument type='datetime' />
Expand All @@ -167,12 +192,28 @@
<argument type='date' />
<argument type='datetime' />
</function>
<function group='operator' name='&lt;=' return-type='bool'>
<formula>(%1 &lt;= %2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='+' return-type='datetime'>
<!-- 86400 as it represents seconds in a day -->
<formula>DATE_ADD(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND)</formula>
<argument type='datetime' />
<argument type='real' />
</function>
<function group='operator' name='+' return-type='datetime'>
<formula>DATE_ADD(%1, INTERVAL %2 DAY)</formula>
<argument type='date' />
<argument type='int' />
</function>
<function group='operator' name='+' return-type='datetime'>
<!-- 86400 as it represents seconds in a day -->
<formula>DATE_ADD(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND)</formula>
<argument type='date' />
<argument type='real' />
</function>
<function group='operator' name='-' return-type='int'>
<formula>(%1 * -1)</formula>
<argument type='int' />
Expand All @@ -189,13 +230,13 @@
</function>
<function group='operator' name='-' return-type='real'>
<!-- 86400 as it represents seconds in a day -->
<formula>((TO_DAYS(%1) - TO_DAYS(CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))) + ((TIME_TO_SEC(%1) - TIME_TO_SEC(CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP))) / 86400.0))</formula>
<formula>(unix_timestamp(%1) - unix_timestamp(%2)) / 86400</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(DATE_FORMAT(%1, '%Y-%m-%d 00:00:00') AS TIMESTAMP))) - TO_DAYS(%1) + ((TIME_TO_SEC(CAST(DATE_FORMAT(%1, '%Y-%m-%d 00:00:00') AS TIMESTAMP)) - TIME_TO_SEC(%2)) / 86400.0))</formula>
<formula>(unix_timestamp(%1) - unix_timestamp(%2)) / 86400</formula>
<argument type='date' />
<argument type='datetime' />
</function>
Expand All @@ -205,6 +246,22 @@
<argument type='datetime' />
<argument type='real' />
</function>
<function group='operator' name='-' return-type='datetime'>
<formula>DATE_SUB(%1, INTERVAL %2 DAY)</formula>
<argument type='date' />
<argument type='int' />
</function>
<function group='operator' name='-' return-type='datetime'>
<!-- 86400 as it represents seconds in a day -->
<formula>DATE_SUB(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND)</formula>
<argument type='date' />
<argument type='real' />
</function>
<function group='operator' name='-' return-type='real'>
<formula>TO_DAYS(%1) - TO_DAYS(%2)</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='operator' name='/' return-type='real'>
<formula>CAST(%1 AS DOUBLE) / %2</formula>
<argument type='int' />
Expand Down Expand Up @@ -262,6 +319,14 @@
<argument type='datetime' />
<argument type='datetime' />
</function>
<function group='numeric' name='MAX' return-type='date'>
<formula>CASE WHEN ISNULL(%1) THEN NULL
WHEN ISNULL(%2) THEN NULL
WHEN %1 &gt; %2 THEN %1
ELSE %2 END</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='numeric' name='MAX' return-type='str'>
<formula>CASE WHEN ISNULL(%1) THEN NULL
WHEN ISNULL(%2) THEN NULL
Expand Down Expand Up @@ -294,6 +359,14 @@
<argument type='datetime' />
<argument type='datetime' />
</function>
<function group='numeric' name='MIN' return-type='date'>
<formula>CASE WHEN ISNULL(%1) THEN NULL
WHEN ISNULL(%2) THEN NULL
WHEN %1 &lt; %2 THEN %1
ELSE %2 END</formula>
<argument type='date' />
<argument type='date' />
</function>
<function group='numeric' name='MIN' return-type='str'>
<formula>CASE WHEN ISNULL(%1) THEN NULL
WHEN ISNULL(%2) THEN NULL
Expand Down
6 changes: 3 additions & 3 deletions bi-connectors/TableauConnector/src/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<connector-plugin class='opensearch_jdbc' superclass='jdbc' plugin-version='2.0.0.0' name='OpenSearch' version='18.1' min-version-tableau='2021.1'>
<vendor-information>
<company name="OpenSearch Project"/>
<support-link url="https://forum.opensearch.org/"/>
<company name="OpenSearch Project"/>
<support-link url="https://forum.opensearch.org/"/>
</vendor-information>
<connection-customization class="opensearch_jdbc" enabled="true" version="10.0">
<vendor name="OpenSearch Project"/>
Expand All @@ -26,7 +26,7 @@
<customization name="CAP_SUPPORTS_SPLIT_FROM_LEFT" value="yes"/>
<customization name="CAP_SUPPORTS_SPLIT_FROM_RIGHT" value="yes"/>
<customization name="CAP_QUERY_ALLOW_PARTIAL_AGGREGATION" value="no"/>
<customization name="CAP_QUERY_TIME_REQUIRES_CAST" value="yes"/>
<customization name="CAP_QUERY_TIME_REQUIRES_CAST" value="no"/>
<customization name="CAP_JDBC_METADATA_USE_RESULTSET_FOR_TABLE" value="yes"/>
<customization name="CAP_JDBC_METADATA_GET_INDEX_INFO" value="no"/>
<customization name="CAP_JDBC_METADATA_IGNORE_NULLABILITY" value="yes"/>
Expand Down