Skip to content

Commit 44eb70c

Browse files
committed
fix decimal parser issue
1 parent 83b6fc3 commit 44eb70c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/sources/ddl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private[sql] class DDLParser extends StandardTokenParsers with PackratParsers wi
5050
lexical.allCaseVersions(k.str).map(x => x : Parser[String]).reduce(_ | _)
5151

5252
protected val CREATE = Keyword("CREATE")
53+
protected val DECIMAL = Keyword("DECIMAL")
5354
protected val TEMPORARY = Keyword("TEMPORARY")
5455
protected val TABLE = Keyword("TABLE")
5556
protected val USING = Keyword("USING")
@@ -104,7 +105,7 @@ private[sql] class DDLParser extends StandardTokenParsers with PackratParsers wi
104105
StructField(name, metastoreTypes.toDataType(typ))
105106
}
106107
|
107-
ident ~ ("decimal" ~ "(" ~> numericLit) ~ ("," ~> numericLit <~ ")") ^^ {
108+
ident ~ (DECIMAL ~ "(" ~> numericLit) ~ ("," ~> numericLit <~ ")") ^^ {
108109
case name ~ precision ~ scale =>
109110
StructField(name, DecimalType(precision.toInt, scale.toInt))
110111
}

sql/core/src/test/scala/org/apache/spark/sql/sources/NewTableScanSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class NewTableScanSuite extends DataSourceTest {
9595
"""
9696
|CREATE TEMPORARY TABLE oneToTen(stringField string, intField int, longField bigint,
9797
|floatField float, doubleField double, shortField smallint, byteField tinyint,
98-
|booleanField boolean, decimalField decimal, dateField date, timestampField timestamp)
98+
|booleanField boolean, decimalField decimal(10,2), dateField date, timestampField timestamp)
9999
|USING org.apache.spark.sql.sources.AllDataTypesScanSource
100100
|OPTIONS (
101101
| From '1',

0 commit comments

Comments
 (0)