diff --git a/cratedb_tableau_jdbc/dialect.tdd b/cratedb_tableau_jdbc/dialect.tdd index d9ada51..b9de682 100644 --- a/cratedb_tableau_jdbc/dialect.tdd +++ b/cratedb_tableau_jdbc/dialect.tdd @@ -411,7 +411,7 @@ - CAST(%1 AS TIMESTAMP) + CAST((CASE WHEN %1 = '' THEN NULL ELSE %1 END) AS TIMESTAMP) @@ -431,7 +431,7 @@ - CAST(%1 AS DOUBLE PRECISION) + (%1 :: DATE) @@ -451,7 +451,9 @@ - CAST(TRUNC(CAST(%1 AS DOUBLE PRECISION)) AS BIGINT) + + CASE WHEN TRY_CAST(%1 AS DATE) IS NOT NULL THEN TRUNC(%1 :: DATE :: DOUBLE PRECISION) :: BIGINT ELSE NULL END + @@ -1110,7 +1112,7 @@ CAST(TRUNC(EXTRACT(%1 FROM %2)) AS INTEGER) - (1 + CAST(EXTRACT(DOW FROM %2) AS INTEGER)) + (CAST(EXTRACT(DOW FROM %2) AS INTEGER)) CAST(FLOOR((7 + EXTRACT(DOY FROM %2) - 1 + EXTRACT(DOW FROM DATE_TRUNC('YEAR', %2))) / 7) AS INTEGER) @@ -1138,7 +1140,7 @@ DATE_TRUNC('%1', %2)::TIMESTAMP - DATE_FORMAT('%j', %2) :: TIMESTAMP + %2:: TIMESTAMP @@ -1156,6 +1158,7 @@ DATE_TRUNC('%1', %2)::TIMESTAMP + %3