-
Notifications
You must be signed in to change notification settings - Fork 60
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
Rename DatePart to DateTimePart #506
Conversation
As DatePart type includes Time components too, rename the type to reflect the current value range. In addition rename the related functions. GitHub Issue: #409
Codecov Report
@@ Coverage Diff @@
## main #506 +/- ##
=========================================
Coverage 82.42% 82.42%
Complexity 1329 1329
=========================================
Files 171 171
Lines 10921 10921
Branches 1795 1795
=========================================
Hits 9002 9002
Misses 1368 1368
Partials 551 551
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Change looks good overall. Left some minor comments about changing datePart
/"date part" to dateTimePart
/"date time part" respectively for consistency with this change.
May want to also do a code search for other comments, functions, and variables that need renamed. E.g.
* Ensures that date parts can be used as variable names. |
@@ -100,9 +100,9 @@ fun ExprValue.stringValue(): String = | |||
fun ExprValue.bytesValue(): ByteArray = | |||
scalar.bytesValue() ?: errNoContext("Expected LOB: $ionValue", internal = false) | |||
|
|||
internal fun ExprValue.datePartValue(): DatePart = | |||
internal fun ExprValue.datePartValue(): DateTimePart = |
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.
May also want to change the name of this extension function to dateTimePartValue()
?
@@ -67,7 +66,7 @@ internal class DateAddExprFunction(valueFactory: ExprValueFactory) : NullPropaga | |||
this.hour, | |||
this.minute, | |||
this.localOffset) | |||
else -> errNoContext("invalid date part for date_add: ${datePart.toString().toLowerCase()}", | |||
else -> errNoContext("invalid date part for date_add: ${dateTimePart.toString().toLowerCase()}", |
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.
Could change error message to say "invalid date time part for ... "
@@ -79,12 +78,12 @@ internal class DateAddExprFunction(valueFactory: ExprValueFactory) : NullPropaga | |||
|
|||
try { | |||
val addedTimestamp = when (datePart) { |
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.
Variable could also be renamed to dateTimePart
and similarly on L79
YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, TIMEZONE_HOUR, TIMEZONE_MINUTE | ||
} | ||
|
||
internal val DATE_PART_KEYWORDS: Set<String> = DatePart.values() | ||
internal val DATE_PART_KEYWORDS: Set<String> = DateTimePart.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.
Variable could be renamed to DATE_TIME_PART_KEYWORDS
for consistency
@@ -73,8 +72,8 @@ class DateAddExprFunctionTest : TestBase() { | |||
.isExactlyInstanceOf(EvaluationException::class.java) | |||
} | |||
|
|||
fun parametersForInvalidDatePart() = listOf(DatePart.TIMEZONE_HOUR, | |||
DatePart.TIMEZONE_MINUTE).map { it.toString().toLowerCase() } | |||
fun parametersForInvalidDatePart() = listOf(DateTimePart.TIMEZONE_HOUR, |
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.
Function could be renamed to parametersForInvalidDateTimePart
@@ -83,19 +83,19 @@ class ExtractEvaluationTest : EvaluatorTestBase() { | |||
data class ExtractFromDateTC(val source: String, val expected: ExprValue?) | |||
|
|||
private fun createDateTC(source: String, expected: LocalDate) = | |||
DatePart.values() | |||
DateTimePart.values() | |||
.map { datePart -> | |||
ExtractFromDateTC( | |||
source = "EXTRACT(${datePart.name} FROM $source)", | |||
expected = when (datePart) { |
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.
Variable could be renamed to dateTimePart
and same with the variable on L127
I think Alan had already figured out few places where the renaming needs to be done. But there are many more occurrences that might have missed. For example, the documentation - |
Good call-outs @abhikuhikar @alancai98, will send a new commit! |
See the list of instances: https://paste.debian.net/hidden/9168be70/
Changed the rest of occurrences, more details of search result here: |
Changes LGTM but can you also rename instances of "datePart" and "date part" in |
That makes sense, will add. |
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.
LGTM. Mind if we merge this PR after the upcoming branch merge to main
? I have some concerns that the files modified here will cause conflicts.
As
DatePart
type includes Time components too, rename the type toreflect the current value range. In addition rename the related
functions.
GitHub Issue: #409
Issue #, if available: 409
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.