milesgranger commented on code in PR #14106: URL: https://github.com/apache/arrow/pull/14106#discussion_r971949459
########## 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(); + std::cout << "About to add to kernel" << std::endl; + DCHECK_OK(func->AddKernel(Type::INT64, {InputType(Type::INT64)}, + out_ty, CastToExtension)); Review Comment: Okay, nice, that is almost where I found myself now, and think I have more headway. Thank you again. -- 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