-4

Basically, I want to create array of date32 type using nice ArrayFromJSON function which is super handy for writing unit tests. I've tried:

auto dateArray = arrow::ArrayFromJSON(arrow::date32(), R"(["2017-11-01"])");

But this doesn't work at least for arrow version is 1.0. Could not find something similar in unit tests.

Kirill Lykov
  • 1,293
  • 2
  • 22
  • 39

1 Answers1

1

Parsing date32 from timestamps is not currently supported by ArayFromJSON; only the integral values are currently accepted:

auto dateArray = arrow::ArrayFromJSON(arrow::date32(), "[17471000]");

Alternatively, you could construct a timestamp array then cast to date32 (but this cast may not be supported in your version of arrow):

auto tsArray = arrow::ArrayFromJSON(arrow::timestamp(TimeUnit::SECOND),
                                    R"(["2017-11-01"])");
auto dateArray = compute::Cast(*tsArray, arrow::date32()).ValueOrDie();
Kietz
  • 1,186
  • 11
  • 19