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

Ángel Álvarez commented on SPARK-9685:
--------------------------------------

I've tried to fix it by adding the "char" DataType to this DataTypeParser class 
...

{code}
    "(?i)timestamp".r ^^^ TimestampType |
    varchar |
    char

  protected lazy val char: Parser[DataType] =
    "(?i)char".r ~> "(" ~> (numericLit <~ ")") ^^^ StringType
{code}

... but now I'm getting this ...

{code}
Exception in thread "main" org.apache.spark.SparkException: Job aborted due to 
stage failure: Task 0.0 in stage 0.0 (TID 0) had a not serializable result: 
org.apache.hadoop.hive.common.type.HiveChar
Serialization stack:
        - object not serializable (class: 
org.apache.hadoop.hive.common.type.HiveChar, value: 00000008)
        - element of array (index: 0)
        - array (class [Ljava.lang.Object;, size 44)
        - field (class: 
org.apache.spark.sql.catalyst.expressions.GenericInternalRow, name: values, 
type: class [Ljava.lang.Object;)
        - object (class 
org.apache.spark.sql.catalyst.expressions.GenericInternalRow, 
[<my_data_fields>])
        - element of array (index: 0)
        - array (class [Lorg.apache.spark.sql.catalyst.InternalRow;, size 21)

{code}

> "Unsupported dataType: char(X)" in Hive
> ---------------------------------------
>
>                 Key: SPARK-9685
>                 URL: https://issues.apache.org/jira/browse/SPARK-9685
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.5.0
>            Reporter: Ángel Álvarez
>
> I'm getting the following error when I try to read a Hive table with char(X) 
> fields:
> {code}
> 15/08/06 11:38:51 INFO parse.ParseDriver: Parse Completed
> org.apache.spark.sql.types.DataTypeException: Unsupported dataType: char(8). 
> 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.
>         at 
> org.apache.spark.sql.types.DataTypeParser$class.toDataType(DataTypeParser.scala:95)
>         at 
> org.apache.spark.sql.types.DataTypeParser$$anon$1.toDataType(DataTypeParser.scala:107)
>         at 
> org.apache.spark.sql.types.DataTypeParser$.parse(DataTypeParser.scala:111)
>         at 
> org.apache.spark.sql.hive.HiveMetastoreTypes$.toDataType(HiveMetastoreCatalog.scala:769)
>         at 
> org.apache.spark.sql.hive.MetastoreRelation$SchemaAttribute.toAttribute(HiveMetastoreCatalog.scala:742)
>         at 
> org.apache.spark.sql.hive.MetastoreRelation$$anonfun$44.apply(HiveMetastoreCatalog.scala:752)
>         at 
> org.apache.spark.sql.hive.MetastoreRelation$$anonfun$44.apply(HiveMetastoreCatalog.scala:752)
> {code}
> It seems there is no "char" DataType defined in the DataTypeParser class
> {code}
>   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 |
>     "(?i)date".r ^^^ DateType |
>     "(?i)timestamp".r ^^^ TimestampType |
>     varchar
> {code}



--
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