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

Fix some date tests #5

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
13 changes: 8 additions & 5 deletions cratedb_tableau_jdbc/dialect.tdd
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
<argument type='real'/>
</function>
<function group='cast' name='DATETIME' return-type='datetime'>
<formula>CAST(%1 AS TIMESTAMP)</formula>
<formula>CAST((CASE WHEN %1 = '' THEN NULL ELSE %1 END) AS TIMESTAMP)</formula>
<argument type='str'/>
</function>
<function group='cast' name='DATETIME' return-type='datetime'>
Expand All @@ -431,7 +431,7 @@
<argument type='real'/>
</function>
<function group='cast' name='FLOAT' return-type='real'>
<formula>CAST(%1 AS DOUBLE PRECISION)</formula>
<formula>(%1 :: DATE)</formula>
<argument type='str'/>
</function>
<function group='cast' name='FLOAT' return-type='real'>
Expand All @@ -451,7 +451,9 @@
<argument type='real'/>
</function>
<function group='cast' name='INT' return-type='int'>
<formula>CAST(TRUNC(CAST(%1 AS DOUBLE PRECISION)) AS BIGINT)</formula>
<formula>
CASE WHEN TRY_CAST(%1 AS DATE) IS NOT NULL THEN TRUNC(%1 :: DATE :: DOUBLE PRECISION) :: BIGINT ELSE NULL END
</formula>
<argument type='str'/>
</function>
<function group='cast' name='INT' return-type='int'>
Expand Down Expand Up @@ -1110,7 +1112,7 @@
</date-function>
<date-function name='DATEPART' return-type='int'>
<formula>CAST(TRUNC(EXTRACT(%1 FROM %2)) AS INTEGER)</formula>
<formula part='weekday'>(1 + CAST(EXTRACT(DOW FROM %2) AS INTEGER))</formula>
<formula part='weekday'>(CAST(EXTRACT(DOW FROM %2) AS INTEGER))</formula>
<formula part='week'>CAST(FLOOR((7 + EXTRACT(DOY FROM %2) - 1 + EXTRACT(DOW FROM DATE_TRUNC(&apos;YEAR&apos;,
%2))) / 7) AS INTEGER)
</formula>
Expand Down Expand Up @@ -1138,7 +1140,7 @@
</date-function>
<date-function name='DATETRUNC' return-type='datetime'>
<formula>DATE_TRUNC('%1', %2)::TIMESTAMP</formula>
<formula part='weekday'>DATE_FORMAT('%j', %2) :: TIMESTAMP</formula>
<formula part='weekday'>%2:: TIMESTAMP</formula>
<argument type='localstr'/>
<argument type='str'/>
</date-function>
Expand All @@ -1156,6 +1158,7 @@
</date-function>
<date-function name='DATETRUNC' return-type='datetime'>
<formula>DATE_TRUNC('%1', %2)::TIMESTAMP</formula>
<formula part="dayofyear">%3</formula>
<argument type='localstr'/>
<argument type='str'/>
<argument type='localstr'/>
Expand Down