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

    https://github.com/apache/incubator-phoenix/pull/22#discussion_r10854046
  
    --- Diff: phoenix-pig/src/main/java/org/apache/phoenix/pig/TypeUtil.java ---
    @@ -185,5 +194,85 @@ public static Object castBytes(Object o, PDataType 
targetPhoenixType) throws IOE
                return o;
             }        
         }
    +    
    +    public static Tuple transformToTuple(final PhoenixRecord record, final 
List<? extends ColumnProjector> projectedColumns) throws IOException {
    +        
    +        List<Object> columnValues = record.getValues();
    +        if(columnValues == null || columnValues.size() == 0 || 
projectedColumns == null || projectedColumns.size() != columnValues.size()) {
    +            return null;
    +        }
    +        int columns = columnValues.size();
    +        Tuple _tuple = TupleFactory.getInstance().newTuple(columns);
    +        try {
    +            for (int i = 0 ; i < columns ; i++) {
    +                ColumnProjector projector = projectedColumns.get(i);
    +                Integer type = 
projector.getExpression().getDataType().getSqlType();
    +                Object obj = columnValues.get(i);
    +                
    +                if (obj == null) {
    +                    _tuple.set(i, null);
    +                    continue;
    +                }
    +
    +                switch (type) {
    +                    case Types.NULL:
    +                        _tuple.set(i, null);
    +                        break;
    +                    case Types.BIGINT:
    +                        if (obj instanceof BigDecimal) {
    +                            Long longValue = DataType.toLong(obj, 
DataType.BIGINTEGER);
    +                            _tuple.set(i, longValue);
    +                            break;
    +                        }
    +                    case Types.INTEGER:
    +                    case Types.TINYINT:
    +                    case Types.SMALLINT:
    +                        _tuple.set(i, new Long((Long) obj).longValue());
    +                        break;
    +                    case Types.DECIMAL:
    +                    case Types.NUMERIC:
    +                    case Types.REAL:
    +                        if (obj instanceof BigDecimal) {
    +                            _tuple.set(i, new Double(((BigDecimal) 
obj).doubleValue()));
    +                            break;
    +                        }
    +                    case Types.FLOAT:
    --- End diff --
    
    FLOAT must be converted to "float" in Pig and not decimal.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to