Skip to content

[C++]: Identity cast for Time64Scalar and Time32Scalar fails #45362

@sgilmore10

Description

@sgilmore10

Describe the bug, including details regarding any error messages, version, and platform.

The identity cast for Time64Scalar and Time32Scalar no longer works as of arrow version 16.1.0.

If this executable:

#include "arrow/scalar.h"
#include "arrow/result.h"
#include "arrow/status.h"
#include <iostream>

arrow::Status test_scalar_cast() {
    auto type =  arrow::time64(arrow::TimeUnit::type::MICRO);//arrow::time64(arrow::TimeUnit::type::MICRO);
    ARROW_ASSIGN_OR_RAISE(auto scalar, arrow::MakeScalar<int64_t>(type, int64_t(1e6)));   
    std::cout << "Casting from time64[us] scalar to time64[us] scalar..." << std::endl;
    ARROW_ASSIGN_OR_RAISE(auto cast_result, scalar->CastTo(type));
    return arrow::Status::OK();
}

int main(int argc, char *argv[]) { 
    auto status = test_scalar_cast();
    if (!status.ok()) {
        std::cout << "Cast failed with message: " << status.message() << std::endl;
    } else {
        std::cout << "Success!" << std::endl;
    }
    return 0;
}

is linked against arrow version 16.1.0, the identity cast fails:

$ ./main
Casting from time64[us] scalar to time64[us] scalar...
Cast failed with message: casting scalars of type time64[us] to type time64[us]

However, if the executable is linked against arrow version 16.0.0, the identity cast works as expected:

$ ./main
Casting from time64[us] scalar to time64[us] scalar...
Success!

I did some code archeology, and I believe this bug was introduced in #40237.

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions