[ 
https://issues.apache.org/jira/browse/HIVE-30165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Denys Kuzmenko updated HIVE-30165:
----------------------------------
    Description: 
{code:sql}                                                                      
                                                                                
                                
  create table t (b tinyint);                                                   
                                                                                
                                  
  insert into t values (7);                                                     
                                                                                
                                  
  set hive.fetch.task.conversion=none;                                          
                                                                                
                                  
  set hive.server2.thrift.resultset.serialize.in.tasks=true;                    
                                                                                
                                  
  select b from t;                                                              
                                                                                
                                  
  {code}         

 The Tez task fails:                                                            
                                                                                
                                 
  {noformat}                                                                    
                                                                                
                                  
  Vertex failed, vertexName=Map 1 ...                                           
                                                                                
                                  
  Caused by: org.apache.hadoop.hive.serde2.SerDeException: 
java.lang.ClassCastException: class java.lang.Byte cannot be cast to class [B   
                                                       
  {noformat}                                                                    
                                                                                
                                  
  With {{serialize.in.tasks=false}} the query returns 7.                        
                                                                                
                                  
                                                                                
                                                                                
                                  
  *Cause:* {{org.apache.hadoop.hive.serde2.thrift.Type.getType(TypeInfo)}} maps 
{{PrimitiveCategory.BYTE}} to {{BINARY_TYPE}}, marked "Double check if this is 
the right mapping" since HIVE-2935.
  {{ThriftJDBCBinarySerDe}} creates its column buffers with {{new 
ColumnBuffer(Type.getType(columnTypes.get(i)))}}. A tinyint column therefore 
gets a binary buffer, and                          
  {{ColumnBuffer.addValue}} casts the {{Byte}} to {{byte[]}}.                   
                                                                                
                                  
  The default path is not affected, because it resolves the type by name 
({{"tinyint"}} -> {{TINYINT_TYPE}}).                                            
                                         
                                                                                
                                                                                
                                  
  *Fix:* map {{BYTE}} to {{TINYINT_TYPE}}. A serde-level test of 
ThriftJDBCBinarySerDe over a tinyint column fails today and passes with the 
fix.                                                 
  

> HS2: TINYINT columns fail with ClassCastException when 
> hive.server2.thrift.resultset.serialize.in.tasks=true
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-30165
>                 URL: https://issues.apache.org/jira/browse/HIVE-30165
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Denys Kuzmenko
>            Priority: Major
>
> {code:sql}                                                                    
>                                                                               
>                                     
>   create table t (b tinyint);                                                 
>                                                                               
>                                       
>   insert into t values (7);                                                   
>                                                                               
>                                       
>   set hive.fetch.task.conversion=none;                                        
>                                                                               
>                                       
>   set hive.server2.thrift.resultset.serialize.in.tasks=true;                  
>                                                                               
>                                       
>   select b from t;                                                            
>                                                                               
>                                       
>   {code}         
>  The Tez task fails:                                                          
>                                                                               
>                                      
>   {noformat}                                                                  
>                                                                               
>                                       
>   Vertex failed, vertexName=Map 1 ...                                         
>                                                                               
>                                       
>   Caused by: org.apache.hadoop.hive.serde2.SerDeException: 
> java.lang.ClassCastException: class java.lang.Byte cannot be cast to class [B 
>                                                          
>   {noformat}                                                                  
>                                                                               
>                                       
>   With {{serialize.in.tasks=false}} the query returns 7.                      
>                                                                               
>                                       
>                                                                               
>                                                                               
>                                       
>   *Cause:* {{org.apache.hadoop.hive.serde2.thrift.Type.getType(TypeInfo)}} 
> maps {{PrimitiveCategory.BYTE}} to {{BINARY_TYPE}}, marked "Double check if 
> this is the right mapping" since HIVE-2935.
>   {{ThriftJDBCBinarySerDe}} creates its column buffers with {{new 
> ColumnBuffer(Type.getType(columnTypes.get(i)))}}. A tinyint column therefore 
> gets a binary buffer, and                          
>   {{ColumnBuffer.addValue}} casts the {{Byte}} to {{byte[]}}.                 
>                                                                               
>                                       
>   The default path is not affected, because it resolves the type by name 
> ({{"tinyint"}} -> {{TINYINT_TYPE}}).                                          
>                                            
>                                                                               
>                                                                               
>                                       
>   *Fix:* map {{BYTE}} to {{TINYINT_TYPE}}. A serde-level test of 
> ThriftJDBCBinarySerDe over a tinyint column fails today and passes with the 
> fix.                                                 
>   



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to