Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-44760: [GLib] Add garrow_record_batch_validate_full() #45386

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions c_glib/arrow-glib/record-batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,24 @@ garrow_record_batch_validate(GArrowRecordBatch *record_batch, GError **error)
return garrow::check(error, arrow_record_batch->Validate(), "[record-batch][validate]");
}

/**
* garrow_record_batch_validate_full
* @record_batch: A #GArrowRecordBatch
* @error: (nullable): Return location for a #GError or %NULL.
*
* Returns: %TRUE on success, %FALSE on error.
*
* Since: 20.0.0
*/
gboolean
garrow_record_batch_validate_full(GArrowRecordBatch *record_batch, GError **error)
{
const auto arrow_record_batch = garrow_record_batch_get_raw(record_batch);
return garrow::check(error,
arrow_record_batch->ValidateFull(),
"[record-batch][validate-full]");
}

typedef struct GArrowRecordBatchIteratorPrivate_
{
arrow::RecordBatchIterator iterator;
Expand Down
4 changes: 4 additions & 0 deletions c_glib/arrow-glib/record-batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ GARROW_AVAILABLE_IN_20_0
gboolean
garrow_record_batch_validate(GArrowRecordBatch *record_batch, GError **error);

GARROW_AVAILABLE_IN_20_0
gboolean
garrow_record_batch_validate_full(GArrowRecordBatch *record_batch, GError **error);

#define GARROW_TYPE_RECORD_BATCH_ITERATOR (garrow_record_batch_iterator_get_type())
GARROW_AVAILABLE_IN_0_17
G_DECLARE_DERIVABLE_TYPE(GArrowRecordBatchIterator,
Expand Down
39 changes: 39 additions & 0 deletions c_glib/test/test-record-batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,44 @@ def test_invalid
end
end
end

sub_test_case("#validate_full") do
def setup
@id_field = Arrow::Field.new("uint8", Arrow::UInt8DataType.new)
@name_field = Arrow::Field.new("string", Arrow::StringDataType.new)
@schema = Arrow::Schema.new([@id_field, @name_field])

@uint8_value = build_uint_array([1])
@valid_name_value = build_string_array(["abc"])
@n_rows = @uint8_value.length

# U+3042 HIRAGANA LETTER A, U+3044 HIRAGANA LETTER I
data = "\u3042\u3044".b[0..-2]
value_offsets = Arrow::Buffer.new([0,data.size].pack("l*"))
@invalid_name_value = Arrow::StringArray.new(1,
value_offsets,
Arrow::Buffer.new(data),
nil,
-1)
end

def test_valid
record_batch = Arrow::RecordBatch.new(@schema, @n_rows, [@uint8_value, @valid_name_value])

assert do
record_batch.validate_full
end
end

def test_invalid
message = "[record-batch][validate-full]: Invalid: " +
"In column 1: Invalid: Invalid UTF8 sequence at string index 0"
record_batch = Arrow::RecordBatch.new(@schema, @n_rows, [@uint8_value, @invalid_name_value])

assert_raise(Arrow::Error::Invalid.new(message)) do
record_batch.validate_full
end
end
end
end
end
Loading