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

Function garrow_array_cast

c_glib/arrow-glib/compute.cpp:4877–4907  ·  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

4875 * Since: 0.7.0
4876 */
4877GArrowArray *
4878garrow_array_cast(GArrowArray *array,
4879 GArrowDataType *target_data_type,
4880 GArrowCastOptions *options,
4881 GError **error)
4882{
4883 auto arrow_array = garrow_array_get_raw(array);
4884 auto arrow_array_raw = arrow_array.get();
4885 auto arrow_target_data_type = garrow_data_type_get_raw(target_data_type);
4886 arrow::Result<std::shared_ptr<arrow::Array>> arrow_casted_array;
4887 if (options) {
4888 auto arrow_options = garrow_cast_options_get_raw(options);
4889 arrow_casted_array =
4890 arrow::compute::Cast(*arrow_array_raw, arrow_target_data_type, *arrow_options);
4891 } else {
4892 arrow_casted_array = arrow::compute::Cast(*arrow_array_raw, arrow_target_data_type);
4893 }
4894 if (garrow::check(error, arrow_casted_array, [&]() {
4895 std::stringstream message;
4896 message << "[array][cast] <";
4897 message << arrow_array->type()->ToString();
4898 message << "> -> <";
4899 message << arrow_target_data_type->ToString();
4900 message << ">";
4901 return message.str();
4902 })) {
4903 return garrow_array_new_raw(&(*arrow_casted_array));
4904 } else {
4905 return NULL;
4906 }
4907}
4908
4909/**
4910 * 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