diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd index f33f42444e..f410db3e2c 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/dialect.tdd @@ -32,6 +32,36 @@ TO_DAYS(%1) - 693961.0 + + CAST(%1 as string) + + + + CAST(%1 as string) + + + + CAST(%1 as string) + + + + CAST(%1 as string) + + + + CAST(%1 as int) + + + + CAST(%1 as int) + + + + + CASE WHEN ISNULL(%1) THEN SUBDATE(TIMESTAMP(%2), INTERVAL HOUR(TIMESTAMP(%2)) HOUR) ELSE %1 END + + + (%1 AND NOT %2 OR NOT %1 AND %2) @@ -150,6 +180,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 @@ -174,7 +212,33 @@ - + + CASE WHEN ISNULL(%1) THEN NULL + WHEN ISNULL(%2) THEN NULL + WHEN %1 < %2 THEN %1 + ELSE %2 END + + + + + CEIL(%1) + + + + FLOOR(%1) + + + + (((CASE WHEN (ABS((%2) - (CAST( ( (%2) / SQRT(3.0) ) AS INT ) * SQRT(3.0)))) + (SQRT(3.0) * ((ABS((%1) - (CAST( ( (%1) / 3.0 ) AS INT ) * 3.0))) - 1.0)) > 0.0 THEN 1.5 ELSE 0.0 END) - (CASE WHEN ((%1) - (CAST( ( (%1) / 3.0 ) AS INT ) * 3.0) < 0.0) AND ((CASE WHEN (ABS((%2) - (CAST( ( (%2) / SQRT(3.0) ) AS INT ) * SQRT(3.0)))) + (SQRT(3.0) * ((ABS((%1) - (CAST( ( (%1) / 3.0 ) AS INT ) * 3.0))) - 1.0)) > 0.0 THEN 1.5 ELSE 0.0 END) > 0.0) THEN 3.0 ELSE 0.0 END)) + (CAST( ( (%1) / 3.0 ) AS INT ) * 3.0)) + + + + + ROUND( (((CASE WHEN (ABS((%2) - (ROUND( ( (%2) / SQRT(3.0) ), 0 ) * SQRT(3.0)))) + (SQRT(3.0) * ((ABS((%1) - (ROUND( ( (%1) / 3.0 ), 0 ) * 3.0))) - 1.0)) > 0.0 THEN SQRT(3.0) / 2.0 ELSE 0.0 END) - (CASE WHEN ((%2) - (ROUND( ( (%2) / SQRT(3.0) ), 0 ) * SQRT(3.0)) < 0.0) AND ((CASE WHEN (ABS((%2) - (ROUND( ( (%2) / SQRT(3.0) ), 0 ) * SQRT(3.0)))) + (SQRT(3.0) * ((ABS((%1) - (ROUND( ( (%1) / 3.0 ), 0 ) * 3.0))) - 1.0)) > 0.0 THEN SQRT(3.0) / 2.0 ELSE 0.0 END) > 0.0) THEN SQRT(3.0) ELSE 0.0 END)) + (ROUND( ( (%2) / SQRT(3.0) ), 0 ) * SQRT(3.0))), 3) + + + + DAY_OF_YEAR(%1) @@ -188,35 +252,35 @@ - + SUBSTR(%1,%2) - + SUBSTR(%1,CAST(%2 as int)) - + SUBSTR(%1,%2,%3) - + SUBSTR(%1,CAST(%2 as int),%3) - + SUBSTR(%1,%2,CAST(%3 as int)) - + SUBSTR(%1,CAST(%2 as int),CAST(%3 as int)) @@ -326,24 +390,8 @@ - - - - - - - - - - - - - - - - diff --git a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/manifest.xml b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/manifest.xml index 20c99b96be..55c64830b9 100644 --- a/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/manifest.xml +++ b/sql-jdbc/src/TableauConnector/opensearch_sql_jdbc/manifest.xml @@ -2,11 +2,11 @@ - + - + diff --git a/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java b/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java index 3ae9463ea4..4dcd94ae74 100644 --- a/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java +++ b/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java @@ -8,6 +8,7 @@ import java.sql.SQLException; import java.sql.Timestamp; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Calendar; import java.util.Map; @@ -78,13 +79,18 @@ else if (value.charAt(23) == '+' || value.charAt(23) == '-') { } } - if (calendar == null) { - return Timestamp.valueOf(value); + final Timestamp ts; + // 11 to check if the value is in yyyy-MM-dd format + if (value.length() < 11) { + ts = Timestamp.valueOf(LocalDate.parse(value).atStartOfDay()); } else { - Timestamp ts = Timestamp.valueOf(value); - return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar); + ts = Timestamp.valueOf(value); } + if (calendar == null) { + return ts; + } + return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar); } catch (IllegalArgumentException iae) { throw stringConversionException(value, iae); }