-
Notifications
You must be signed in to change notification settings - Fork 61
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
[DRAFT] Defines spi.datetime classes #1656
Conversation
CROSS-ENGINE-REPORT ❌
Testing Details
Result Details
Now FAILING Tests ❌The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact. Now IGNORED Tests ❌The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact. Now Passing Tests17 test(s) were previously failing in BASE (LEGACY-V0.14.8) but now pass in TARGET (EVAL-11B3DA9). Before merging, confirm they are intended to pass. The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact. CROSS-COMMIT-REPORT ❌
Testing DetailsResult Details
Now FAILING Tests ❌The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean APIs. I haven't gone through all of it yet, but have some immediate questions.
* This class represents a PartiQL Interval value. SQL defines two "classes" of intervals: year-month and day-time. | ||
* In Java these are represented by {@link Period} and {@link Duration} respectively. | ||
*/ | ||
public interface Interval { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these variants, are you planning on adding getters for the fields? (years, months, etc)
partiql-spi/src/main/java/org/partiql/spi/datetime/Interval.java
Outdated
Show resolved
Hide resolved
public static YM days(int days) { | ||
return new YM(Period.ofDays(days)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If strictly SQL, days should return a DT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly SQL, just adding our own surface to Period/Duration. I don't like the split that much to be honest and I had started on our own interval which is when I realized I didn't want to re-invent datetime things. I do think our own interval could simplify things though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to flatten our values a bit more, these could immediately be Datum
implementations. And Datum
can expose the static methods. For example, Datum.intervalYearToMonth(int years, int months)
returns the package private DatumIntervalYM
implementation.
Same could go for Datum.intervalDayToHour(int days, int hours)
, Datum.intervalDayToMinute(int days, int hours, int minutes)
, etc pointing to the package private DatumIntervalDT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but I was hoping to separate our datetime impls from the Datum, since the Datum could just wrap them like it does now. But also there's no good reason for them to exist outside of Datum. Kind of like DatumDecimal wraps BigDecimal; we have the DatumDate/DatumTime today wrapping the existing Datetime stuff.
I'll work to internalize as much as possible behind Datum, ideally one day we actually do use stack values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Left small comments. I'd like to see these APIs used in practice, so once the build and conformance tests pass, I can approve.
* will throw this exception upon invocation. | ||
* @throws NullPointerException if this instance also returns true on {@link #isNull()}; callers should check that | ||
* {@link #isNull()} returns false before attempting to invoke this method. | ||
* @return a {@link LocalDate} for DATE, TIMESTAMP, and TIMESTAMPZ types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking -- Given TIMESTAMP/Z has getLocalDateTime
, this may be redundant. Same goes for getLocalTime
.
Datum.integer(v.minute) | ||
} | ||
|
||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to delete these?
Sounds good, I didn't want to sink a bunch of time into updating function impls until the APIs were finalized. |
3fa3853
to
a083184
Compare
Reduced scope and pushed as #1691 |
Description
This PR works on cleaning up and finalizing the Datetime classes in accordance with the SQL specification with some minor changes. It also introduces the INTERVAL type which may be split into INTERVALYM and INTERVALDS and can be easily converted to a packed byte[] representation. This is a draft until the existing ones are replaced.
See #1654
Other Information
and Code Style Guidelines? YES
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
< If YES, which ones and why? >
< In addition, please also mention any other alternatives you've considered and the reason they've been discarded >
Do your changes comply with the Contributing Guidelines
and Code Style Guidelines? [YES/NO]
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.