Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b75a80f
Add Millennium
MaxGekk Sep 29, 2019
b233c90
Add Century
MaxGekk Sep 29, 2019
6f017a6
Add Decade
MaxGekk Sep 29, 2019
ac1c3a8
Add Year
MaxGekk Sep 29, 2019
7265508
Add Quarter
MaxGekk Sep 29, 2019
554df71
Move MONTHS_PER_QUARTER up
MaxGekk Sep 29, 2019
d0f89f4
Eliminate a warning
MaxGekk Sep 30, 2019
8174fd5
Extend with ExpectsInputTypes
MaxGekk Sep 30, 2019
6378b95
Remove blank lines
MaxGekk Sep 30, 2019
8e4ca7d
Add Month
MaxGekk Sep 30, 2019
8ed01c7
Week is not supported by PostgreSQL
MaxGekk Sep 30, 2019
f1eea12
Remove not-supported fields
MaxGekk Sep 30, 2019
561f789
Week of interval is not supported
MaxGekk Sep 30, 2019
0a671a9
Add Day
MaxGekk Sep 30, 2019
894a6c7
Add Hour
MaxGekk Sep 30, 2019
f86f4f5
Change Month type to ByteType
MaxGekk Sep 30, 2019
283fd99
Change Quarter type to ByteType
MaxGekk Sep 30, 2019
5e189ca
Put common code to IntervalPart
MaxGekk Sep 30, 2019
62c21b9
Run scalafmt
MaxGekk Sep 30, 2019
a4fbb5e
Add Minute
MaxGekk Sep 30, 2019
e1c9415
Add Second
MaxGekk Sep 30, 2019
7f4100f
Run scalafmt
MaxGekk Sep 30, 2019
f3cf7f0
Refactoring
MaxGekk Sep 30, 2019
9262f9d
Add a test for overflow
MaxGekk Sep 30, 2019
b9890ec
Add Milliseconds
MaxGekk Sep 30, 2019
bea3faf
Add Microseconds
MaxGekk Sep 30, 2019
77e0fb3
Add Epoch
MaxGekk Sep 30, 2019
58017a7
Support intervals by date_part
MaxGekk Sep 30, 2019
f5620b3
Update comments for DatePart
MaxGekk Sep 30, 2019
dcaf5b2
Regenerate results of date_part.sql
MaxGekk Sep 30, 2019
f202b15
Add tests for intervals to date_part.sql
MaxGekk Sep 30, 2019
dca29e5
Remove wrong test
MaxGekk Sep 30, 2019
f8a2385
Make Dongjoon and Scala style checker happy
MaxGekk Oct 1, 2019
7b1663e
Merge remote-tracking branch 'remotes/origin/master' into extract-fro…
MaxGekk Oct 8, 2019
8a494a2
Improve an example
MaxGekk Oct 8, 2019
f08531b
Precise epoch calculation from intervals
MaxGekk Oct 8, 2019
e8a61c8
Fix expected results in IntervalExpressionsSuite
MaxGekk Oct 8, 2019
f8a45b3
Revert "Precise epoch calculation from intervals"
MaxGekk Oct 12, 2019
a496d73
Precise calculation micros per month
MaxGekk Oct 12, 2019
47a0290
Revert "Precise calculation micros per month"
MaxGekk Oct 18, 2019
2099a91
Fix expected results in IntervalExpressionsSuite
MaxGekk Oct 18, 2019
d4375b5
Add the Extract prefix to all classes
MaxGekk Oct 18, 2019
5620472
Change indentation for extends to 2 spaces
MaxGekk Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Minute
  • Loading branch information
MaxGekk committed Sep 30, 2019
commit a4fbb5e314141bfc5a60d64ab6164c9585d70946
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ case class Day(child: Expression) extends IntervalPart(child, LongType, getDay,

case class Hour(child: Expression) extends IntervalPart(child, ByteType, getHour, "getHour")

case class Minute(child: Expression) extends IntervalPart(child, ByteType, getMinute, "getMinute")

object IntervalPart {

def parseExtractField(
Expand All @@ -78,7 +80,7 @@ object IntervalPart {
case "MONTH" | "MON" | "MONS" | "MONTHS" => Month(source)
case "DAY" | "D" | "DAYS" => Day(source)
case "HOUR" | "H" | "HOURS" | "HR" | "HRS" => Hour(source)
// case "MINUTE" | "M" | "MIN" | "MINS" | "MINUTES" => Minute(source)
case "MINUTE" | "M" | "MIN" | "MINS" | "MINUTES" => Minute(source)
// case "SECOND" | "S" | "SEC" | "SECONDS" | "SECS" => Second(source)
// case "MILLISECONDS" | "MSEC" | "MSECS" | "MILLISECON" | "MSECONDS" | "MS" =>
// Milliseconds(source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object IntervalUtils {
val YEARS_PER_CENTURY: Int = 100
val YEARS_PER_DECADE: Int = 10
val MICROS_PER_HOUR: Long = DateTimeUtils.MILLIS_PER_HOUR * DateTimeUtils.MICROS_PER_MILLIS
val MICROS_PER_MINUTE: Long = DateTimeUtils.MILLIS_PER_MINUTE * DateTimeUtils.MICROS_PER_MILLIS

def getYear(interval: CalendarInterval): Int = {
interval.months / MONTHS_PER_YEAR
Expand Down Expand Up @@ -58,4 +59,8 @@ object IntervalUtils {
def getHour(interval: CalendarInterval): Byte = {
((interval.microseconds % DateTimeUtils.MICROS_PER_DAY) / MICROS_PER_HOUR).toByte
}

def getMinute(interval: CalendarInterval): Byte = {
((interval.microseconds % MICROS_PER_HOUR) / MICROS_PER_MINUTE).toByte
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,16 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
checkEvaluation(Hour(
"9999 years 11 months 31 days 11 hours 59 minutes 59 seconds"), 11.toByte)
}

test("minute") {
checkEvaluation(Minute("0 minute"), 0.toByte)
checkEvaluation(Minute("1 minute"), 1.toByte)
checkEvaluation(Minute("-1 minute"), -1.toByte)
checkEvaluation(Minute("59 minute"), 59.toByte)
checkEvaluation(Minute("-59 minute"), -59.toByte)
// Years and months must not be taken into account
checkEvaluation(Minute("100 year 10 months 10 minutes"), 10.toByte)
checkEvaluation(Minute(
"9999 years 11 months 31 days 11 hours 59 minutes 59 seconds"), 59.toByte)
}
}