Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/317#discussion_r206328431
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java ---
    @@ -204,14 +205,19 @@ private void appendPKColumnValue(StringBuilder buf, 
byte[] range, Boolean isNull
                 range = ptr.get();
             }
             if (changeViewIndexId) {
    -            Short s = (Short) type.toObject(range);
    -            s = (short) (s + (-Short.MAX_VALUE));
    -            buf.append(s.toString());
    +            PDataType viewIndexDataType = 
tableRef.getTable().getViewIndexType();
    +            buf.append(getViewIndexValue(type, range, 
viewIndexDataType).toString());
             } else {
                 Format formatter = context.getConnection().getFormatter(type);
                 buf.append(type.toStringLiteral(range, formatter));
             }
         }
    +
    +    private Long getViewIndexValue(PDataType type, byte[] range, PDataType 
viewIndexDataType){
    +        boolean useLongViewIndex = 
MetaDataUtil.getViewIndexIdDataType().equals(viewIndexDataType);
    +        Object s =  type.toObject(range);
    +        return (useLongViewIndex ? (Long) s : (Short) s) - 
(useLongViewIndex ? Long.MAX_VALUE : Short.MAX_VALUE);
    --- End diff --
    
    Shouldn't the <type> argument be all that's necessary? Why is an additional 
type argument needed? The type as defined in the schema should be the right 
type, no?


---

Reply via email to