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

Implements date_add builtin in partiql-eval #1334

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

yliuuuu
Copy link
Contributor

@yliuuuu yliuuuu commented Jan 10, 2024

Relevant Issues

  • [Closes/Related To] Issue #XXX

Description

  • Modified Header to remove unsupported function for FnDateAdd and FnDateDiff.
    • This is, when the Date Time Field is not in the operand(s), we should not generate a function. I.e., when add 1 minute to a date type should not be supported.
  • Implemented FnDateAdd.
  • I did not implemented FnDateDiff. To implemented this, we need to make modification to either PartiQL Value or adding session attribute to PartiQL Function's invoke API.

Consider the function to be date_diff(MINUTE, TIME '00:00:00', TIME WITH TIME ZONE '01:00:00+01:00') and the session time zone is UTC. then the result should be 0.

We need the session time zone to convert the first Time value to Time With Time Zone value to do the comparison.

Other Information

  • Updated Unreleased Section in CHANGELOG: [YES/NO]

    • No. Internal.
  • Any backward-incompatible changes? [YES/NO]

    • No.
  • Any new external dependencies? [YES/NO]

    • < If YES, which ones and why? >
    • < In addition, please also mention any other alternatives you've considered and the reason they've been discarded >
    • No.
  • Do your changes comply with the Contributing Guidelines
    and Code Style Guidelines? [YES/NO]

  • Yes.

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

Conformance comparison report

Base (c5dae43) 2018d34 +/-
% Passing 92.54% 92.54% 0.00%
✅ Passing 5384 5384 0
❌ Failing 434 434 0
🔶 Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5384

Number failing in both: 434

Number passing in Base (c5dae43) but now fail: 0

Number failing in Base (c5dae43) but now pass: 0

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (partiql-plugin-impl@c5dae43). Click here to learn what that means.

Additional details and impacted files
@@                  Coverage Diff                   @@
##             partiql-plugin-impl    #1334   +/-   ##
======================================================
  Coverage                       ?   49.27%           
  Complexity                     ?     1046           
======================================================
  Files                          ?      166           
  Lines                          ?    13395           
  Branches                       ?     2504           
======================================================
  Hits                           ?     6600           
  Misses                         ?     6138           
  Partials                       ?      657           
Flag Coverage Δ
CLI 11.86% <0.00%> (?)
EXAMPLES 80.28% <0.00%> (?)
LANG 54.71% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RCHowell RCHowell changed the title Partiql plugin impl fn date add Implements date_add builtin in partiql-eval Jan 11, 2024
Comment on lines +41 to +49
val interval = args[0].check<Int32Value>()
val datetime = args[1].check<DateValue>()
return if (datetime.value == null || interval.value == null) {
dateValue(null)
} else {
val datetimeValue = datetime.value!!
val intervalValue = interval.long!!
dateValue(datetimeValue.plusDays(intervalValue))
}
Copy link
Member

Choose a reason for hiding this comment

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

As discussed on tuesday, we should unbox and non-null assert for null calls as the engine checks the arguments before invoking the function.

Suggested change
val interval = args[0].check<Int32Value>()
val datetime = args[1].check<DateValue>()
return if (datetime.value == null || interval.value == null) {
dateValue(null)
} else {
val datetimeValue = datetime.value!!
val intervalValue = interval.long!!
dateValue(datetimeValue.plusDays(intervalValue))
}
val interval = args[0].check<Int32Value>()!!
val datetime = args[1].check<DateValue>()!!
return dateValue(datetime.plusDays(interval))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do that and all others in a follow up PR if ok with you.

Copy link
Member

Choose a reason for hiding this comment

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

Good idea.

@RCHowell RCHowell merged commit 1dabd4e into partiql-plugin-impl Jan 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants