wangyum commented on a change in pull request #23899: 
[SPARK-26969][spark-thriftserver] Bigdecimal values shall be converted to 
HiveDecimal type for succesful processing of query using ODBC interface
URL: https://github.com/apache/spark/pull/23899#discussion_r305799266
 
 

 ##########
 File path: 
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/ColumnValue.java
 ##########
 @@ -193,7 +193,7 @@ public static TColumnValue toTColumnValue(Type type, 
Object value) {
     case INTERVAL_DAY_TIME_TYPE:
       return stringValue((HiveIntervalDayTime) value);
     case DECIMAL_TYPE:
-      return stringValue(((HiveDecimal)value));
+      return getDecimalType(value);
 
 Review comment:
   The reason is your client protocol version is lower than 
`HIVE_CLI_SERVICE_PROTOCOL_V6`:
   
https://github.com/apache/spark/blob/02c33694c8254f69cb36c71c0876194dccdbc014/sql/hive-thriftserver/v1.2.1/src/main/java/org/apache/hive/service/cli/RowSetFactory.java#L28-L40
   
   The fix is correct, but I'd like make it more clear:
   ```diff
   +++ 
b/sql/hive-thriftserver/v1.2.1/src/main/java/org/apache/hive/service/cli/ColumnValue.java
   @@ -23,7 +23,6 @@ import java.sql.Date;
    import java.sql.Timestamp;
    
    import org.apache.hadoop.hive.common.type.HiveChar;
   -import org.apache.hadoop.hive.common.type.HiveDecimal;
    import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
    import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
    import org.apache.hadoop.hive.common.type.HiveVarchar;
   @@ -139,11 +138,10 @@ public class ColumnValue {
        return TColumnValue.stringVal(tStringValue);
      }
    
   -  private static TColumnValue stringValue(HiveDecimal value, TypeDescriptor 
typeDescriptor) {
   +  private static TColumnValue stringValue(BigDecimal value, TypeDescriptor 
typeDescriptor) {
        TStringValue tStrValue = new TStringValue();
        if (value != null) {
   -      int scale = typeDescriptor.getDecimalDigits();
   -      tStrValue.setValue(value.toFormatString(scale));
   +      tStrValue.setValue(value.toPlainString());
        }
        return TColumnValue.stringVal(tStrValue);
      }
   @@ -197,7 +195,7 @@ public class ColumnValue {
        case INTERVAL_DAY_TIME_TYPE:
          return stringValue((HiveIntervalDayTime) value);
        case DECIMAL_TYPE:
   -      return stringValue((HiveDecimal)value, typeDescriptor);
   +      return stringValue((BigDecimal)value, typeDescriptor);
        case BINARY_TYPE:
          return stringValue((String)value);
        case ARRAY_TYPE:
   ```
   
   We can verify it by https://github.com/apache/spark/pull/25228

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to