This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new e32f56b478 GH-44762: [GLib] Add garrow_table_validate_full() (#45468)
e32f56b478 is described below
commit e32f56b478171fc4b53dc2042c4cf5d37c97e351
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Sun Feb 9 19:25:37 2025 +0900
GH-44762: [GLib] Add garrow_table_validate_full() (#45468)
### Rationale for this change
[Table::ValidateFull](https://arrow.apache.org/docs/cpp/api/table.html#_CPPv4NK5arrow5Table12ValidateFullEv)
available in the C++ API.
But, GLib doesn't support that method yet.
### What changes are included in this PR?
This PR adds a full validation method to the table class.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* GitHub Issue: #44762
Lead-authored-by: Hiroyuki Sato <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
c_glib/arrow-glib/table.cpp | 18 ++++++++++++++++++
c_glib/arrow-glib/table.h | 4 ++++
c_glib/test/test-table.rb | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+)
diff --git a/c_glib/arrow-glib/table.cpp b/c_glib/arrow-glib/table.cpp
index 7b11ae342c..4595ae7593 100644
--- a/c_glib/arrow-glib/table.cpp
+++ b/c_glib/arrow-glib/table.cpp
@@ -754,6 +754,24 @@ garrow_table_validate(GArrowTable *table, GError **error)
return garrow::check(error, arrow_table->Validate(), "[table][validate]");
}
+/**
+ * garrow_table_validate_full
+ * @table: A #GArrowTable
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Validate the given table. This is an extensive validation.
+ *
+ * Returns: %TRUE on success, %FALSE on error.
+ *
+ * Since: 20.0.0
+ */
+gboolean
+garrow_table_validate_full(GArrowTable *table, GError **error)
+{
+ const auto arrow_table = garrow_table_get_raw(table);
+ return garrow::check(error, arrow_table->ValidateFull(),
"[table][validate-full]");
+}
+
typedef struct GArrowFeatherWritePropertiesPrivate_
{
arrow::ipc::feather::WriteProperties properties;
diff --git a/c_glib/arrow-glib/table.h b/c_glib/arrow-glib/table.h
index 184c7c8f38..a78ee47fc9 100644
--- a/c_glib/arrow-glib/table.h
+++ b/c_glib/arrow-glib/table.h
@@ -146,6 +146,10 @@ GARROW_AVAILABLE_IN_20_0
gboolean
garrow_table_validate(GArrowTable *table, GError **error);
+GARROW_AVAILABLE_IN_20_0
+gboolean
+garrow_table_validate_full(GArrowTable *table, GError **error);
+
#define GARROW_TYPE_FEATHER_WRITE_PROPERTIES
(garrow_feather_write_properties_get_type())
GARROW_AVAILABLE_IN_0_17
G_DECLARE_DERIVABLE_TYPE(GArrowFeatherWriteProperties,
diff --git a/c_glib/test/test-table.rb b/c_glib/test/test-table.rb
index 8e11340094..1c8c6fb3f7 100644
--- a/c_glib/test/test-table.rb
+++ b/c_glib/test/test-table.rb
@@ -274,6 +274,46 @@ valid:
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])
+
+ @id_values = build_uint_array([1])
+ @valid_name_values = build_string_array(["abc"])
+
+ # 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_values = Arrow::StringArray.new(1,
+ value_offsets,
+ Arrow::Buffer.new(data),
+ nil,
+ -1)
+ end
+
+ def test_valid
+ columns = [@id_values, @valid_name_values]
+ table = Arrow::Table.new(@schema, columns)
+
+ assert do
+ table.validate_full
+ end
+ end
+
+ def test_invalid
+ message = "[table][validate-full]: Invalid: " +
+ "Column 1: In chunk 0: Invalid: Invalid UTF8 sequence at string
index 0"
+ columns = [@id_values, @invalid_name_values]
+ table = Arrow::Table.new(@schema, columns)
+
+ assert_raise(Arrow::Error::Invalid.new(message)) do
+ table.validate_full
+ end
+ end
+ end
+
sub_test_case("#write_as_feather") do
def setup
super