Skip to content

Commit

Permalink
fix decimal parser issue
Browse files Browse the repository at this point in the history
  • Loading branch information
scwf committed Dec 30, 2014
1 parent 83b6fc3 commit 44eb70c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private[sql] class DDLParser extends StandardTokenParsers with PackratParsers wi
lexical.allCaseVersions(k.str).map(x => x : Parser[String]).reduce(_ | _)

protected val CREATE = Keyword("CREATE")
protected val DECIMAL = Keyword("DECIMAL")
protected val TEMPORARY = Keyword("TEMPORARY")
protected val TABLE = Keyword("TABLE")
protected val USING = Keyword("USING")
Expand Down Expand Up @@ -104,7 +105,7 @@ private[sql] class DDLParser extends StandardTokenParsers with PackratParsers wi
StructField(name, metastoreTypes.toDataType(typ))
}
|
ident ~ ("decimal" ~ "(" ~> numericLit) ~ ("," ~> numericLit <~ ")") ^^ {
ident ~ (DECIMAL ~ "(" ~> numericLit) ~ ("," ~> numericLit <~ ")") ^^ {
case name ~ precision ~ scale =>
StructField(name, DecimalType(precision.toInt, scale.toInt))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class NewTableScanSuite extends DataSourceTest {
"""
|CREATE TEMPORARY TABLE oneToTen(stringField string, intField int, longField bigint,
|floatField float, doubleField double, shortField smallint, byteField tinyint,
|booleanField boolean, decimalField decimal, dateField date, timestampField timestamp)
|booleanField boolean, decimalField decimal(10,2), dateField date, timestampField timestamp)
|USING org.apache.spark.sql.sources.AllDataTypesScanSource
|OPTIONS (
| From '1',
Expand Down

0 comments on commit 44eb70c

Please sign in to comment.