[ 
https://issues.apache.org/jira/browse/SPARK-11628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14998348#comment-14998348
 ] 

zhangshunyu commented on SPARK-11628:
-------------------------------------

I think that if we add 3 lines in the file 
"spark\sql\types\DataTypeParser.scala", this problem would be solved:
protected lazy val primitiveType: Parser[DataType] =
    "(?i)string".r ^^^ StringType |
    "(?i)float".r ^^^ FloatType |
    "(?i)(?:int|integer)".r ^^^ IntegerType |
    "(?i)tinyint".r ^^^ ByteType |
    "(?i)smallint".r ^^^ ShortType |
    "(?i)double".r ^^^ DoubleType |
    "(?i)(?:bigint|long)".r ^^^ LongType |
    "(?i)binary".r ^^^ BinaryType |
    "(?i)boolean".r ^^^ BooleanType |
    fixedDecimalType |
    "(?i)decimal".r ^^^ DecimalType.USER_DEFAULT |
    fixedDecType |
    "(?i)dec".r ^^^ DecimalType.USER_DEFAULT |
    fixedNumericType |
    "(?i)numeric".r ^^^ DecimalType.USER_DEFAULT |
    "(?i)date".r ^^^ DateType |
    "(?i)timestamp".r ^^^ TimestampType |
    varchar|
++ char
   
 
++  protected lazy val char: Parser[DataType] =
++  "(?i)char".r ~> "(" ~> (numericLit <~ ")") ^^^ StringType

> spark-sql do not support for column datatype of CHAR
> ----------------------------------------------------
>
>                 Key: SPARK-11628
>                 URL: https://issues.apache.org/jira/browse/SPARK-11628
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.5.1
>            Reporter: zhangshunyu
>              Labels: features
>
> In spark-sql when we create a table using the command as follwing:
>        "create table tablename(col char(5));"
> Hive will support for creating the table,  but when we desc the table:
>        "desc tablename"
> spark will report the error:
>        “org.apache.spark.sql.types.DataTypeException: Unsupported dataType: 
> char(5). If you have a struct and a field name of it has any special 
> characters, please use backticks (`) to quote that field name, e.g. `x+y`. 
> Please note that backtick itself is not supported in a field name.”



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to