You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Aleksey Plekhanov (Jira)" <ji...@apache.org> on 2021/07/20 12:45:00 UTC

[jira] [Commented] (IGNITE-14960) Calcite engine. EXTRACT(DOW FROM d) returns invalid results

    [ https://issues.apache.org/jira/browse/IGNITE-14960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17384225#comment-17384225 ] 

Aleksey Plekhanov commented on IGNITE-14960:
--------------------------------------------

[~tledkov-gridgain] what documentation are you referred to?

According to calcite documentation, DOW can't return 0:
|DAYOFWEEK(date)|Equivalent to {{EXTRACT(DOW FROM date)}}. Returns an integer between 1 and 7.|

And according to comments in implementation DOW should return 1 for Sunday and 7 for Saturday

There is also ISODOW date part exists, which returns 1 for Monday and 7 for Sunday.

Looks like there is no common standard and every vendor have it's own implementation, for example:
 * PostgreeSQL has EXTRACT(DOW) function which returns 0 for Sunday and TO_CHAR(..., 'D') function which returns 1 for Sunday
 * MySQL has DAYOFWEEK function which returns 1 for Sunday
 * H2 has DAY_OF_WEEK function which returns 1 for Sunday and ISO_DAY_OF_WEEK function which returns 1 for Monday.

And looks like the current calcite behavior match H2 behavior and will minimize compatibility issues

 

 

> Calcite engine. EXTRACT(DOW FROM d) returns invalid results
> -----------------------------------------------------------
>
>                 Key: IGNITE-14960
>                 URL: https://issues.apache.org/jira/browse/IGNITE-14960
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Taras Ledkov
>            Priority: Major
>
> The query
> {{SELECT EXTRACT(DOW FROM CAST('1993-08-14' AS DATE))}}
> return *7*.
> According with documentation:
> *dow* - The day of the week as Sunday(0) to Saturday(6)
> Tests:
> {{function/date/test_extract.test}}
> {{function/date/test_extract_edge_cases.test}}
> {{function/timestamp/test_extract.test}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)