You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2020/11/28 21:58:25 UTC
[arrow] branch master updated: ARROW-10752: [GLib] Add
garrow_schema_has_metadata()
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new a8bebed ARROW-10752: [GLib] Add garrow_schema_has_metadata()
a8bebed is described below
commit a8bebed13df484aa9348f3ebaefebc5abd1a7a3a
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Sun Nov 29 06:57:16 2020 +0900
ARROW-10752: [GLib] Add garrow_schema_has_metadata()
Closes #8787 from kou/glib-schema-has-metadata
Authored-by: Sutou Kouhei <ko...@clear-code.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
c_glib/arrow-glib/schema.cpp | 15 +++++++++++++++
c_glib/arrow-glib/schema.h | 3 +++
c_glib/test/test-schema.rb | 15 +++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/c_glib/arrow-glib/schema.cpp b/c_glib/arrow-glib/schema.cpp
index 62a36de..bf66f56 100644
--- a/c_glib/arrow-glib/schema.cpp
+++ b/c_glib/arrow-glib/schema.cpp
@@ -360,6 +360,21 @@ garrow_schema_replace_field(GArrowSchema *schema,
}
/**
+ * garrow_schema_has_metadata:
+ * @schema: A #GArrowSchema.
+ *
+ * Returns: %TRUE if the schema has metadata, %FALSE otherwise.
+ *
+ * Since: 3.0.0
+ */
+gboolean
+garrow_schema_has_metadata(GArrowSchema *schema)
+{
+ const auto arrow_schema = garrow_schema_get_raw(schema);
+ return arrow_schema->HasMetadata();
+}
+
+/**
* garrow_schema_get_metadata:
* @schema: A #GArrowSchema.
*
diff --git a/c_glib/arrow-glib/schema.h b/c_glib/arrow-glib/schema.h
index f97f997..3a3252b 100644
--- a/c_glib/arrow-glib/schema.h
+++ b/c_glib/arrow-glib/schema.h
@@ -66,6 +66,9 @@ GArrowSchema *garrow_schema_replace_field (GArrowSchema *schema,
GArrowField *field,
GError **error);
+GARROW_AVAILABLE_IN_3_0
+gboolean
+garrow_schema_has_metadata(GArrowSchema *schema);
GARROW_AVAILABLE_IN_0_17
GHashTable *
garrow_schema_get_metadata(GArrowSchema *schema);
diff --git a/c_glib/test/test-schema.rb b/c_glib/test/test-schema.rb
index 87a38ac..a82d3f9 100644
--- a/c_glib/test/test-schema.rb
+++ b/c_glib/test/test-schema.rb
@@ -164,6 +164,21 @@ new: bool
SCHEMA
end
+ def test_has_metadata
+ fields = [
+ Arrow::Field.new("enabled", Arrow::BooleanDataType.new),
+ Arrow::Field.new("required", Arrow::BooleanDataType.new),
+ ]
+ schema = Arrow::Schema.new(fields)
+ assert do
+ not schema.has_metadata?
+ end
+ schema_with_metadata = schema.with_metadata("key" => "value")
+ assert do
+ schema_with_metadata.has_metadata?
+ end
+ end
+
sub_test_case("#metadata") do
def setup
require_gi_bindings(3, 4, 2)