-
Notifications
You must be signed in to change notification settings - Fork 62
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
Timestamp Data Model #1121
Timestamp Data Model #1121
Conversation
Conformance comparison report
Number passing in both: 5376 Number failing in both: 442 Number passing in Base (2283db5) but now fail: 0 Number failing in Base (2283db5) but now pass: 0 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1121 +/- ##
============================================
+ Coverage 73.19% 73.30% +0.10%
- Complexity 2376 2400 +24
============================================
Files 237 238 +1
Lines 17261 17444 +183
Branches 3133 3158 +25
============================================
+ Hits 12635 12787 +152
- Misses 3653 3674 +21
- Partials 973 983 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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 is an awesome piece of work. Left some comments -- the only two files I have yet to go through are TimestampTests and PartiQLParserDateTimeTests.
/** | ||
* Counting the time escaped from midnight 00:00:00 in seconds ( fraction included) | ||
*/ | ||
val elapsedSecond: BigDecimal by lazy { |
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.
internal
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.
And, roundToPrecision
can use this value.
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 may not need to be internal as this is a commonly exposed property in java's time package.
Maybe keep it as is and wait for the evaluation PR to confirm?
partiql-types/src/main/kotlin/org/partiql/value/datetime/Time.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/value/datetime/TimeZone.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/value/datetime/Timestamp.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/value/datetime/Timestamp.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/value/datetime/Timestamp.kt
Outdated
Show resolved
Hide resolved
partiql-lang/src/main/kotlin/org/partiql/lang/syntax/util/DateTimeUtils.kt
Outdated
Show resolved
Hide resolved
partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/test/kotlin/org/partiql/datetime/TimestampTest.kt
Outdated
Show resolved
Hide resolved
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.
Address feedback
/** | ||
* Counting the time escaped from midnight 00:00:00 in seconds ( fraction included) | ||
*/ | ||
val elapsedSecond: BigDecimal by lazy { |
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 may not need to be internal as this is a commonly exposed property in java's time package.
Maybe keep it as is and wait for the evaluation PR to confirm?
} | ||
|
||
val epochMillis: BigDecimal by lazy { | ||
epochSecond.movePointRight(3) |
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 should be safe.
partiql-types/src/main/kotlin/org/partiql/value/datetime/Timestamp.kt
Outdated
Show resolved
Hide resolved
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.
Overall very impressive. This is a ton of work. Just a few comments as I took a cursory review. I will look more into this tomorrow. Thank you.
public override val year: Int? | ||
get() = null | ||
|
||
/** | ||
* Month field for [Time] is always null | ||
*/ | ||
public override val month: Int? | ||
get() = null | ||
|
||
/** | ||
* Day field for [Time] is always null | ||
*/ | ||
public override val day: Int? | ||
get() = null |
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.
Why getters? Can you just assign null?
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.
Property initializers are not allowed in interfaces.
public abstract class DateImpl : Date, Comparable<Date> { | ||
public final override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other?.javaClass != javaClass) return false | ||
other as DateImpl | ||
if (this.year != other.year) return false | ||
if (this.month != other.month) return false | ||
if (this.day != other.day) return false | ||
return true | ||
} | ||
|
||
public final override fun hashCode(): Int = | ||
year.hashCode() + month.hashCode() + day.hashCode() | ||
|
||
public final override fun toString(): String = | ||
"${this.javaClass.simpleName}(year=$year, month=$month, day=$day)" | ||
} |
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.
Why not make Date
the abstract class with these default implementations?
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.
The original thought was to accommodate the possibility of having to implement different date system. Maybe I am overcomplicating this stuff and we would never need this...
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.
Wow -- this is quite a lot of work. Great job. As for the creation of low/high precision datetimes, I didn't find anything wrong. I had some questions offline, but it all looked good.
I had one small nit about a function name and a test method, but beyond that, it LGTM.
* Returns a [Date] value with the specified number of months added. | ||
* [years] can be negative. | ||
*/ | ||
public fun plusYear(years: Long): Date |
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.
Nit -- plusYears
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.
Also, specified number of years added in the KDoc.
// negative epoch | ||
// May be Ion has a bug? | ||
// Expected epoch in Millis : -23225270400000, | ||
// Actual epoch in Millis : -23225875200000 | ||
// SuccessCaseWithNoTimeZone( | ||
// 1234, 1, 1, 0,0, BigDecimal.valueOf(0,3), 0, | ||
// Timestamp.of( | ||
// DateTimeValue.date(1234, 1, 1), | ||
// DateTimeValue.time(0,0, BigDecimal.valueOf(0,0), ) | ||
// ), | ||
// ), |
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.
While the matching SuccessCaseWithUnknownTimeZone
fails -- would this one also fail? This specific test case shouldn't be comparing Ion values if I'm reading this correctly.
Relevant Issues
Description
This PR is a POC on Timestamp Type.
This PR covers the Timestamp Data Model, and enable timestamp constructor in Parser.
This PR does not cover any aspect of evaluation yet, as covering those will create too big a diff for reviewer.
Other Information
Updated Unreleased Section in CHANGELOG: [YES/NO]
Any backward-incompatible changes? [YES/NO]
Any new external dependencies? [YES/NO]
Do your changes comply with the Contributing Guidelines
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.