Skip to content

Commit 0814fc4

Browse files
committed
fix '.111'
1 parent 79f5892 commit 0814fc4

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ object IntervalUtils {
427427
state = TRIM_BEFORE_SIGN
428428
case TRIM_BEFORE_SIGN => trimToNextState(b, SIGN)
429429
case SIGN =>
430+
currentValue = 0
431+
fraction = 0
432+
// Sets the scale to an invalid value to track fraction presence
433+
// in the BEGIN_UNIT_NAME state
434+
fractionScale = -1
435+
state = TRIM_BEFORE_VALUE
430436
b match {
431437
case '-' =>
432438
isNegative = true
@@ -436,14 +442,13 @@ object IntervalUtils {
436442
i += 1
437443
case _ if '0' <= b && b <= '9' =>
438444
isNegative = false
445+
case '.' =>
446+
isNegative = false
447+
i += 1
448+
fractionScale = (NANOS_PER_SECOND / 10).toInt
449+
state = VALUE_FRACTIONAL_PART
439450
case _ => exceptionWithState( s"Unrecognized sign '$nextWord'")
440451
}
441-
currentValue = 0
442-
fraction = 0
443-
// Sets the scale to an invalid value to track fraction presence
444-
// in the BEGIN_UNIT_NAME state
445-
fractionScale = -1
446-
state = TRIM_BEFORE_VALUE
447452
case TRIM_BEFORE_VALUE => trimToNextState(b, VALUE)
448453
case VALUE =>
449454
b match {

sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLParserSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ class DDLParserSuite extends AnalysisTest with SharedSparkSession {
789789
assertError("select interval '23:61:15' hour to second",
790790
"minute 61 outside range [0, 59]")
791791
assertError("select interval '.1111111111' second",
792-
"Invalid interval string")
792+
"invalid value fractional part '1111111111'")
793793
}
794794

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

0 commit comments

Comments
 (0)