0

I am trying to read a parquet file and store it in custom C structure to further use in my C code

case arrow::Type::DECIMAL:
{
    const arrow::Decimal128Type* decimal_type = static_cast<const arrow::Decimal128Type*>(arrow_table_->column(i)->type().get());
    int32_t precision = decimal_type->precision();
    int32_t scale = decimal_type->scale();
    pArrowTableDef->columns[i].array->type = DECIMAL_TYPE;
    pArrowTableDef->columns[i].array->length = pArrowTableDef->num_rows;
    pArrowTableDef->columns[i].array->data = new ArrowDecimal[pArrowTableDef->num_rows];
    for (int row_index = 0; row_index < pArrowTableDef->num_rows; ++row_index) {
        std::shared_ptr<arrow::Decimal128Array> decimal_array = std::static_pointer_cast<arrow::Decimal128Array>(chunked_array->chunk(row_index / chunk_length));
        arrow::Decimal128 value = decimal_array->Value(row_index % chunk_length);
        ArrowDecimal& arrow_decimal = static_cast<ArrowDecimal*>(pArrowTableDef->columns[i].array->data)[row_index];
        arrow_decimal.value = value.low_bits();
        arrow_decimal.precision = precision;
        arrow_decimal.scale = scale;
    }
}

Getting error: ** error: conversion from ‘const uint8_t* {aka const unsigned char*}’ to non-scalar type ‘arrow::Decimal128’ requested**

Custom C structure:

typedef struct {
    int64_t value;     // Store the raw integer value of the decimal
    int precision;     // Store the precision of the decimal
    int scale;         // Store the scale of the decimal
} ArrowDecimal;

typedef struct {
    FieldType type;
    void *data;
    int length;
    int precision;
    int scale;
} ArrowArray;
typedef struct {
    char *name;
    ArrowArray *array;
} ArrowColumn;
typedef struct {
    int num_rows;
    int num_cols;
    ArrowColumn *columns;
} ArrowTableDef;

I tried using arrow::Buffer as well, but that didnt work

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90

0 Answers0