Skip to content

[C++] Add Compute Kernel for Casting from list_view to list #39051

@llama90

Description

@llama90

Describe the enhancement requested

This is a sub-issue of the issue mentioned below.

As we can see in the parent issue, we can find tables organizing the related functions.

file name code snippet
scalar_test.cc EXPECT_OK_AND_ASSIGN(auto cast_scalar, scalar.CastTo(to_type));
scalar_test.cc scalar.CastTo(to_type);

The functions require handling "Unsupported cast from list_view<item: int16> to list using function cast_list" error.

We need to implement casting from list_view to list.

Warning

In this case, The additional casting function would vary depending on whether the CheckListCast or CheckInvalidListCast functions are called.

scalar_test.cc

Snippet to reproduce

template <typename ScalarType>
void CheckListCast(const ScalarType& scalar, const std::shared_ptr<DataType>& to_type) {
- EXPECT_OK_AND_ASSIGN(auto cast_scalar, scalar.CastTo(to_type));
- ASSERT_OK(cast_scalar->ValidateFull());
- ASSERT_EQ(*cast_scalar->type, *to_type);
+ EXPECT_OK_AND_ASSIGN(auto cast_scalar, Cast(scalar, to_type));
+ ASSERT_OK(cast_scalar.scalar()->ValidateFull());
+ ASSERT_EQ(*cast_scalar.scalar()->type, *to_type);

- ASSERT_EQ(scalar.is_valid, cast_scalar->is_valid);
+ ASSERT_EQ(scalar.is_valid, cast_scalar.scalar()->is_valid);
  ASSERT_TRUE(scalar.is_valid);
  ASSERT_ARRAYS_EQUAL(*scalar.value,
-                     *checked_cast<const BaseListScalar&>(*cast_scalar).value);
+                     *checked_cast<const BaseListScalar&>(*cast_scalar.scalar()).value);
}

void CheckInvalidListCast(const Scalar& scalar, const std::shared_ptr<DataType>& to_type,
                          const std::string& expected_message) {
  EXPECT_RAISES_WITH_CODE_AND_MESSAGE_THAT(StatusCode::Invalid,
                                           ::testing::HasSubstr(expected_message),
-                                          scalar.CastTo(to_type));
+                                          Cast(scalar, to_type));
}

Sub-task

  • Support list_view to list
  • Support list_view to fixed_size_list
  • Fix CheckInvalidListCast for TestMapScalar

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions