将拼花地板FIXED_LEN_BYTE_ARRAY转换为 DECIMAL 在本机 Java 映射 reduce 中



我的底层数据是使用 HIVE 输出格式(org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat)写入的)

尝试使用本机 Java Map Reduce 读取此数据

byte[] b = value.getBinary(value.getType().getFieldIndex(field), 0).getBytes();
HiveDecimal hd = HiveDecimal.create(b, true);

这里的值是org.apache.parquet.example.data.Group在这种情况下,HD类型变为NULL。

但是下面适用于字符串/整数类型。

value.getValueToString(value.getType().getFieldIndex(field), 0);

没关系,我找到了一种方法,使用 DecimalUtils 来自Parquet Decimal Type 到 Java BigDecimal 在 Pig 中的转换。

添加链接用于DecimalUtils的Github链接

相关内容

最新更新