Skip to content

Conversation

@kumarUjjawal
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

The Date - Date currently returns duration which is not consistent with other databases.

What changes are included in this PR?

  • Made changes to so it return Int instead of the days duration
  • Added slt test

Are these changes tested?

Yes

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) labels Dec 30, 2025
@kumarUjjawal kumarUjjawal force-pushed the fix/date_duration_type branch 2 times, most recently from 2b09623 to c7de274 Compare December 30, 2025 18:49
@Omega359
Copy link
Contributor

It seems to me that mapping the binary op's duration result to an int64 taking into account the timeunit and mod to get the day would be cleaner?

@kumarUjjawal
Copy link
Contributor Author

It seems to me that mapping the binary op's duration result to an int64 taking into account the timeunit and mod to get the day would be cleaner?

Thanks of the feedback.

@kumarUjjawal kumarUjjawal force-pushed the fix/date_duration_type branch from c7de274 to 902bb07 Compare January 2, 2026 05:51
Comment on lines 105 to 109
# Verify Date - Date returns Int64 type
query T
SELECT arrow_typeof(DATE '2023-04-09' - DATE '2023-04-02');
----
Int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests seem duplicated with what we already have in arith_date_date.slt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are, though the arith_* files came in after these tests existed and I didn't noticed until after that PR had merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the duplicate test.

kumarUjjawal and others added 2 commits January 3, 2026 18:44
Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com>
// Special case: Date - Date should return Int64 (days difference)
// This aligns with PostgreSQL, DuckDB, and MySQL behavior
// See: https://www.postgresql.org/docs/current/functions-datetime.html
if matches!(self.op, Minus) && is_date_minus_date(lhs, rhs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed if the above suggestion was applied

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date - Date returns a type inconsistent with other databases

3 participants