A R
A R

Reputation: 11

Convert Parquet FIXED_LEN_BYTE_ARRAY into a DECIMAL in native Java map reduce

My underlying data is written using HIVE output format (org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat)

Trying to read this data using native Java Map reduce

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

HiveDecimal hd = HiveDecimal.create(b, true);

value here is org.apache.parquet.example.data.Group type hd in this case becomes NULL.

But below works just fine for string/int types.

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

Upvotes: 0

Views: 4999

Answers (1)

A R
A R

Reputation: 11

Never mind, I found a way by using DecimalUtils from Parquet Decimal Type to Java BigDecimal conversion in Pig.

Adding link Github link for DecimalUtils

Upvotes: 1

Related Questions