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

[C++][Gandiva] TO_DATE unction returns wrong date for pattern YYYY-MM #37608

Closed
DenisTarasyuk opened this issue Sep 7, 2023 · 0 comments · Fixed by #37609
Closed

[C++][Gandiva] TO_DATE unction returns wrong date for pattern YYYY-MM #37608

DenisTarasyuk opened this issue Sep 7, 2023 · 0 comments · Fixed by #37609

Comments

@DenisTarasyuk
Copy link
Contributor

Describe the bug, including details regarding any error messages, version, and platform.

When function TO_DATE is called with pattern 'YYYY-MM' it will return date which has -1 day offset to expected. For example to_date('2022-11', 'YYYY-MM') will return 1667174400000 which is 2022-10-31. Problem is caused by strptime returning 0 in result.tm_mday if day is not part of format. This will cause result to be -1 day from expected.

Component(s)

C++, C++ - Gandiva

@DenisTarasyuk DenisTarasyuk changed the title TO_DATE Gandiva function retruns wrong date for pattern YYYY-MM TO_DATE Gandiva function returns wrong date for pattern YYYY-MM Sep 7, 2023
@kou kou changed the title TO_DATE Gandiva function returns wrong date for pattern YYYY-MM [C++][Gandiva] TO_DATE Gandiva function returns wrong date for pattern YYYY-MM Sep 8, 2023
@kou kou changed the title [C++][Gandiva] TO_DATE Gandiva function returns wrong date for pattern YYYY-MM [C++][Gandiva] TO_DATE unction returns wrong date for pattern YYYY-MM Sep 8, 2023
@kou kou closed this as completed in #37609 Sep 8, 2023
kou pushed a commit that referenced this issue Sep 8, 2023
…37609)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: #37608

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
@kou kou added this to the 14.0.0 milestone Sep 8, 2023
DenisTarasyuk added a commit to dremio/arrow that referenced this issue Sep 8, 2023
…YYYY (apache#37609)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
DenisTarasyuk added a commit to dremio/arrow that referenced this issue Sep 11, 2023
…YYYY (apache#37609) (#48)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>

Signed-off-by: Sutou Kouhei <[email protected]>
DenisTarasyuk added a commit to dremio/arrow that referenced this issue Sep 26, 2023
…YYYY (apache#37609)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
DenisTarasyuk added a commit to dremio/arrow that referenced this issue Oct 11, 2023
…YYYY (apache#37609) (#48)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>

Signed-off-by: Sutou Kouhei <[email protected]>
xxlaykxx pushed a commit to dremio/arrow that referenced this issue Oct 29, 2023
…YYYY (apache#37609) (#48)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>

Signed-off-by: Sutou Kouhei <[email protected]>
DenisTarasyuk added a commit to dremio/arrow that referenced this issue Nov 2, 2023
…YYYY (apache#37609) (#48)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>

Signed-off-by: Sutou Kouhei <[email protected]>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…YYYY (apache#37609)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…YYYY (apache#37609)

Added fix for case when pattern does not contain day part

### Rationale for this change

TO_DATE Gandiva function returns wrong result if used with pattern 'YYYY-MM' or 'YYYY'.

### What changes are included in this PR?

Add a fix for case when tm_mday is zero to set it to 1

### Are these changes tested?

Added tests that cover described cases

### Are there any user-facing changes?

No

* Closes: apache#37608

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants