Skip to content

Commit

Permalink
fix '.111'
Browse files Browse the repository at this point in the history
  • Loading branch information
yaooqinn committed Nov 13, 2019
1 parent 79f5892 commit 0814fc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ object IntervalUtils {
state = TRIM_BEFORE_SIGN
case TRIM_BEFORE_SIGN => trimToNextState(b, SIGN)
case SIGN =>
currentValue = 0
fraction = 0
// Sets the scale to an invalid value to track fraction presence
// in the BEGIN_UNIT_NAME state
fractionScale = -1
state = TRIM_BEFORE_VALUE
b match {
case '-' =>
isNegative = true
Expand All @@ -436,14 +442,13 @@ object IntervalUtils {
i += 1
case _ if '0' <= b && b <= '9' =>
isNegative = false
case '.' =>
isNegative = false
i += 1
fractionScale = (NANOS_PER_SECOND / 10).toInt
state = VALUE_FRACTIONAL_PART
case _ => exceptionWithState( s"Unrecognized sign '$nextWord'")
}
currentValue = 0
fraction = 0
// Sets the scale to an invalid value to track fraction presence
// in the BEGIN_UNIT_NAME state
fractionScale = -1
state = TRIM_BEFORE_VALUE
case TRIM_BEFORE_VALUE => trimToNextState(b, VALUE)
case VALUE =>
b match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ class DDLParserSuite extends AnalysisTest with SharedSparkSession {
assertError("select interval '23:61:15' hour to second",
"minute 61 outside range [0, 59]")
assertError("select interval '.1111111111' second",
"Invalid interval string")
"invalid value fractional part '1111111111'")
}

test("use native json_tuple instead of hive's UDTF in LATERAL VIEW") {
Expand Down

0 comments on commit 0814fc4

Please sign in to comment.