From d62d23f66fbb7242e5468695a9f4eb90c0909f11 Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Thu, 18 Nov 2021 18:52:21 -0800 Subject: [PATCH 1/4] Added few functions to compare date and datetimes to fix some test cases in 'operator.date' test (AOS-203) Signed-off-by: Yury Fridlyand --- .../opensearch_sql_jdbc/dialect.tdd | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd index 73cc10a08c..50c5865021 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd @@ -63,16 +63,87 @@ + + + (TIMESTAMP(%1) = TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) = TIMESTAMP(%2)) + + + - (CAST(DATE_FORMAT(DATE(%1), '%Y-%m-%d 00:00:00') AS TIMESTAMP) <> %2) + (TIMESTAMP(%1) <> TIMESTAMP(%2)) - (%1 <> CAST(DATE_FORMAT(DATE(%2), '%Y-%m-%d 00:00:00') AS TIMESTAMP)) + (TIMESTAMP(%1) <> TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) >= TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) >= TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) <= TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) <= TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) > TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) > TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) < TIMESTAMP(%2)) + + + + + (TIMESTAMP(%1) < TIMESTAMP(%2)) + + + + + + + ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + + + + + + ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + + + ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + + + + DATE_ADD(DATE_ADD(%1, INTERVAL FLOOR(%2) DAY), INTERVAL CAST(86400 * (%2 - FLOOR(%2)) AS INT) SECOND) From 96ac3ca0710339ea506c9296353e783a7b3fd12d Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Fri, 19 Nov 2021 11:15:51 -0800 Subject: [PATCH 2/4] Using CAST instead of type conversion because it has higher performance Signed-off-by: Yury Fridlyand --- .../opensearch_sql_jdbc/dialect.tdd | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd index 50c5865021..d8bba00142 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd @@ -65,81 +65,81 @@ - (TIMESTAMP(%1) = TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) = CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) = TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) = CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) <> TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) <> CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) <> TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) <> CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) >= TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) >= CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) >= TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) >= CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) <= TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) <= CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) <= TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) <= CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) > TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) > CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) > TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) > CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) < TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) < CAST(%2 as TIMESTAMP)) - (TIMESTAMP(%1) < TIMESTAMP(%2)) + (CAST(%1 as TIMESTAMP) < CAST(%2 as TIMESTAMP)) - ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + ((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)) - ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + ((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)) - ((TO_DAYS(TIMESTAMP(%1)) - TO_DAYS(TIMESTAMP(%2))) + ((TIME_TO_SEC(TIMESTAMP(%1)) - TIME_TO_SEC(TIMESTAMP(%2))) / 86400.0)) + ((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)) From be77676f211aa112b870373ff737adf79c87dfd5 Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Fri, 19 Nov 2021 15:48:24 -0800 Subject: [PATCH 3/4] Added DATE_FORMAT because CAST to TIMESTAMP doesn't work for all types Signed-off-by: Yury Fridlyand --- .../opensearch_sql_jdbc/dialect.tdd | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd index d8bba00142..0c87ffe749 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd @@ -65,62 +65,62 @@ - (CAST(%1 as TIMESTAMP) = CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) = CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) <> CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) <> CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) >= CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) >= CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) <= CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) <= CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) > CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) > CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) < CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(%1 as TIMESTAMP) < CAST(%2 as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) From 634d4e8796c357110b7055d2fb21b01426f5d695 Mon Sep 17 00:00:00 2001 From: Yury Fridlyand Date: Fri, 19 Nov 2021 16:02:48 -0800 Subject: [PATCH 4/4] Typo fix Signed-off-by: Yury Fridlyand --- .../opensearch_sql_jdbc/dialect.tdd | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd index 0c87ffe749..eae38cf89c 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd @@ -65,27 +65,27 @@ - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) = CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) <> CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') AS TIMESTAMP)) >= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) @@ -95,32 +95,32 @@ - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) <= CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) > CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) - (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) + (CAST(DATE_FORMAT(%1, '%Y-%m-%d %H:%i:%s') as TIMESTAMP)) < CAST(DATE_FORMAT(%2, '%Y-%m-%d %H:%i:%s') as TIMESTAMP))