MCPcopy Create free account
hub / github.com/apache/arrow / garrow_array_cast

Function garrow_array_cast

c_glib/arrow-glib/compute.cpp:4922–4952  ·  view source on GitHub ↗

* garrow_array_cast: * @array: A #GArrowArray. * @target_data_type: A #GArrowDataType of cast target data. * @options: (nullable): A #GArrowCastOptions. * @error: (nullable): Return location for a #GError or %NULL. * * Returns: (nullable) (transfer full): * A newly created casted array on success, %NULL on error. * * Since: 0.7.0 */

Source from the content-addressed store, hash-verified

4920 * Since: 0.7.0
4921 */
4922GArrowArray *
4923garrow_array_cast(GArrowArray *array,
4924 GArrowDataType *target_data_type,
4925 GArrowCastOptions *options,
4926 GError **error)
4927{
4928 auto arrow_array = garrow_array_get_raw(array);
4929 auto arrow_array_raw = arrow_array.get();
4930 auto arrow_target_data_type = garrow_data_type_get_raw(target_data_type);
4931 arrow::Result<std::shared_ptr<arrow::Array>> arrow_casted_array;
4932 if (options) {
4933 auto arrow_options = garrow_cast_options_get_raw(options);
4934 arrow_casted_array =
4935 arrow::compute::Cast(*arrow_array_raw, arrow_target_data_type, *arrow_options);
4936 } else {
4937 arrow_casted_array = arrow::compute::Cast(*arrow_array_raw, arrow_target_data_type);
4938 }
4939 if (garrow::check(error, arrow_casted_array, [&]() {
4940 std::stringstream message;
4941 message << "[array][cast] <";
4942 message << arrow_array->type()->ToString();
4943 message << "> -> <";
4944 message << arrow_target_data_type->ToString();
4945 message << ">";
4946 return message.str();
4947 })) {
4948 return garrow_array_new_raw(&(*arrow_casted_array));
4949 } else {
4950 return NULL;
4951 }
4952}
4953
4954/**
4955 * garrow_array_unique:

Callers

nothing calls this directly

Calls 10

garrow_data_type_get_rawFunction · 0.85
CastFunction · 0.85
garrow_array_new_rawFunction · 0.85
strMethod · 0.80
garrow_array_get_rawFunction · 0.70
checkFunction · 0.70
getMethod · 0.45
ToStringMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected