Skip to content

Commit c6b6bfb

Browse files
GH-44758: [GLib] Add garrow_array_validate_full() (#45342)
### Rationale for this change [Array::ValidateFull](https://arrow.apache.org/docs/cpp/api/array.html#_CPPv4NK5arrow5Array12ValidateFullEv) available in the C++ API. But, GLib doesn't support that method yet. ### What changes are included in this PR? This PR adds a validation method in the array class. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #44758 Authored-by: Hiroyuki Sato <hiroysato@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent f4a63d4 commit c6b6bfb

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

c_glib/arrow-glib/basic-array.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,22 @@ garrow_array_validate(GArrowArray *array, GError **error)
10331033
return garrow::check(error, arrow_array->Validate(), "[array][validate]");
10341034
}
10351035

1036+
/**
1037+
* garrow_array_validate_full:
1038+
* @array: A #GArrowArray.
1039+
* @error: (nullable): Return location for a #GError or %NULL.
1040+
*
1041+
* Returns: %TRUE on success, %FALSE on error.
1042+
*
1043+
* Since: 20.0.0
1044+
*/
1045+
gboolean
1046+
garrow_array_validate_full(GArrowArray *array, GError **error)
1047+
{
1048+
const auto arrow_array = garrow_array_get_raw(array);
1049+
return garrow::check(error, arrow_array->ValidateFull(), "[array][validate_full]");
1050+
}
1051+
10361052
G_DEFINE_TYPE(GArrowNullArray, garrow_null_array, GARROW_TYPE_ARRAY)
10371053

10381054
static void

c_glib/arrow-glib/basic-array.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ GARROW_AVAILABLE_IN_20_0
130130
gboolean
131131
garrow_array_validate(GArrowArray *array, GError **error);
132132

133+
GARROW_AVAILABLE_IN_20_0
134+
gboolean
135+
garrow_array_validate_full(GArrowArray *array, GError **error);
136+
133137
#define GARROW_TYPE_NULL_ARRAY (garrow_null_array_get_type())
134138
GARROW_AVAILABLE_IN_ALL
135139
G_DECLARE_DERIVABLE_TYPE(

c_glib/test/test-array.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,30 @@ def test_invalid
202202
end
203203
end
204204
end
205+
206+
sub_test_case("#validate_full") do
207+
def test_valid
208+
array = build_int32_array([1, 2, 3, 4, 5])
209+
assert do
210+
array.validate_full
211+
end
212+
end
213+
214+
def test_invalid
215+
message = "[array][validate_full]: Invalid: Invalid UTF8 sequence at string index 0"
216+
217+
# U+3042 HIRAGANA LETTER A, U+3044 HIRAGANA LETTER I
218+
data = "\u3042\u3044".b[0..-2]
219+
value_offsets = Arrow::Buffer.new([0, data.size].pack("l*"))
220+
array = Arrow::StringArray.new(1,
221+
value_offsets,
222+
Arrow::Buffer.new(data),
223+
Arrow::Buffer.new([0b01].pack("C*")),
224+
-1)
225+
226+
assert_raise(Arrow::Error::Invalid.new(message)) do
227+
array.validate_full
228+
end
229+
end
230+
end
205231
end

0 commit comments

Comments
 (0)