From 0f82db24bb64b0bbb09ff16ffb1790d976bf1747 Mon Sep 17 00:00:00 2001 From: Guian Gumpac Date: Wed, 14 Jun 2023 08:43:36 -0700 Subject: [PATCH] Add functions for date type in the TACO (#5) * Added fixes for some date/time functions Signed-off-by: Guian Gumpac * Added functions for date agg and operations Signed-off-by: Guian Gumpac --------- Signed-off-by: Guian Gumpac --- .../TableauConnector/src/dialect.tdd | 77 ++++++++++++++++++- .../TableauConnector/src/manifest.xml | 6 +- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/bi-connectors/TableauConnector/src/dialect.tdd b/bi-connectors/TableauConnector/src/dialect.tdd index 0e5dd37..b2e0723 100644 --- a/bi-connectors/TableauConnector/src/dialect.tdd +++ b/bi-connectors/TableauConnector/src/dialect.tdd @@ -87,6 +87,11 @@ + + (%1 = %2) + + + (%1 AND NOT %2 OR NOT %1 AND %2) @@ -127,6 +132,11 @@ + + (%1 <> %2) + + + (%1 > CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP)) @@ -137,6 +147,11 @@ + + (%1 > %2) + + + (%1 >= CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP)) @@ -147,6 +162,11 @@ + + (%1 >= %2) + + + (%1 < CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP)) @@ -157,6 +177,11 @@ + + (%1 < %2) + + + (%1 <= CAST(DATE_FORMAT(%2, '%Y-%m-%d 00:00:00') AS TIMESTAMP)) @@ -167,12 +192,28 @@ + + (%1 <= %2) + + + DATE_ADD(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND) + + DATE_ADD(%1, INTERVAL %2 DAY) + + + + + + DATE_ADD(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND) + + + (%1 * -1) @@ -189,13 +230,13 @@ - ((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)) + (unix_timestamp(%1) - unix_timestamp(%2)) / 86400 - ((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)) + (unix_timestamp(%1) - unix_timestamp(%2)) / 86400 @@ -205,6 +246,22 @@ + + DATE_SUB(%1, INTERVAL %2 DAY) + + + + + + DATE_SUB(%1, INTERVAL CAST((86400 * %2) AS INT) SECOND) + + + + + TO_DAYS(%1) - TO_DAYS(%2) + + + CAST(%1 AS DOUBLE) / %2 @@ -262,6 +319,14 @@ + + CASE WHEN ISNULL(%1) THEN NULL + WHEN ISNULL(%2) THEN NULL + WHEN %1 > %2 THEN %1 + ELSE %2 END + + + CASE WHEN ISNULL(%1) THEN NULL WHEN ISNULL(%2) THEN NULL @@ -294,6 +359,14 @@ + + CASE WHEN ISNULL(%1) THEN NULL + WHEN ISNULL(%2) THEN NULL + WHEN %1 < %2 THEN %1 + ELSE %2 END + + + CASE WHEN ISNULL(%1) THEN NULL WHEN ISNULL(%2) THEN NULL diff --git a/bi-connectors/TableauConnector/src/manifest.xml b/bi-connectors/TableauConnector/src/manifest.xml index 0fe6f88..5bb3ea0 100644 --- a/bi-connectors/TableauConnector/src/manifest.xml +++ b/bi-connectors/TableauConnector/src/manifest.xml @@ -2,8 +2,8 @@ - - + + @@ -26,7 +26,7 @@ - +