milesgranger commented on code in PR #14106: URL: https://github.com/apache/arrow/pull/14106#discussion_r971836443
########## cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc: ########## @@ -769,6 +770,41 @@ std::vector<std::shared_ptr<CastFunction>> GetNumericCasts() { return functions; } + +Status CastToExtension(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { + const CastOptions& options = checked_cast<const CastState*>(ctx->state())->options; + + DCHECK(batch[0].is_array()); + std::shared_ptr<Array> array = batch[0].array.ToArray(); + std::shared_ptr<Array> result; + auto ext_ty = GetExtensionType(kOutputTargetType.type()->name()); + if (ext_ty == nullptr) { + return Status::Invalid("Could not find extension type: " + kOutputTargetType.type()->name()); + } + auto out_ty = ext_ty->storage_type(); + RETURN_NOT_OK(Cast(*array, out_ty, options, + ctx->exec_context()) + .Value(&result)); + ExtensionArray extension(ext_ty, result); + out->value = std::move(extension.data()); + return Status::OK(); +} + +std::shared_ptr<CastFunction> GetCastToExtension(std::string name) { + auto func = std::make_shared<CastFunction>(std::move(name), Type::EXTENSION); + auto out_ty = kOutputTargetType.type(); Review Comment: @rok I feel like I've exhausted my debugging options here. While I know these functions are in the wrong file.. was trying to get a working prototype. However, this line here aborts: ```python In [1]: import pyarrow as pa In [2]: from pyarrow.tests.test_extension_type import UuidType, IntegerType In [3]: a = pa.array([1, 2, 3], pa.int64()) In [4]: a.cast(IntegerType()) /home/milesg/Projects/arrow/cpp/src/arrow/compute/kernel.cc:382: Check failed: (FIXED) == (kind_) ``` Do you have any suggestions? -- edit: See I ought to be using `kOutputTargetType.resolver()` for use with COMPUTED, most likely, to trying that now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org