How to get an Arrow's Array's TimeUnit C++

81 Views Asked by At

It's a very simple example. I am trying to extract the TimeUnit::type from the DataType.

array = arrow::Array *array

auto a = static_cast<arrow::Date64Array*>(array);            
arrow::TimeUnit::type unit =  a->type()->unit();

I didn't find any specific in the Docs but the type.h says that there should be a public .Unit or .unit() but I can't find any of them. Did I miss something?

1

There are 1 best solutions below

0
On BEST ANSWER

My C++ is a little bit slow, and partially looks like arrow::DateUnit is not exported in the C++ api for whatever reason.

array = arrow::Array *array
auto &ty = static_cast<arrow::Time64Type&>(*array->type());
arrow::DateUnit unit = ty.unit();

As a bonus I was trying to do this for timestamp (and other times) as well, which is slightly different since they return arrow::TimeUnit::type instead:

array = arrow::Array *array
auto &ty = static_cast<arrow::TimestampType&>(*array->type());
arrow::TimeUnit::type unit = ty.unit();