Skip to content

Commit

Permalink
test schema
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Nov 22, 2023
1 parent 391580d commit 5f3350e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nanoarrow/nanoarrow_testing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class TestingJSONWriter {
return EINVAL;
}

out << "{";

// Write fields
out << R"("fields": )";
if (schema->n_children == 0) {
Expand All @@ -69,6 +71,7 @@ class TestingJSONWriter {
out << R"(, "metadata": )";
NANOARROW_RETURN_NOT_OK(WriteMetadata(out, schema->metadata));

out << "}";
return NANOARROW_OK;
}

Expand Down
15 changes: 15 additions & 0 deletions src/nanoarrow/nanoarrow_testing_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ TEST(NanoarrowTestingTest, NanoarrowTestingTestBatch) {
R"({"count": 0, "columns": []})");
}

TEST(NanoarrowTestingTest, NanoarrowTestingTestSchema) {
TestColumn(
[](ArrowSchema* schema) {
ArrowSchemaInit(schema);
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetTypeStruct(schema, 2));
NANOARROW_RETURN_NOT_OK(
ArrowSchemaSetType(schema->children[0], NANOARROW_TYPE_NA));
NANOARROW_RETURN_NOT_OK(
ArrowSchemaSetType(schema->children[1], NANOARROW_TYPE_STRING));
return NANOARROW_OK;
},
[](ArrowArray* array) { return NANOARROW_OK; }, &WriteSchemaJSON,
R"({"fields": [{"name": null, "nullable": true, "type": {"name": "null"}, "children": [], "metadata": null}, {"name": null, "nullable": true, "type": {"name": "utf8"}, "children": [], "metadata": null}], "metadata": null})");
}

TEST(NanoarrowTestingTest, NanoarrowTestingTestFieldBasic) {
TestColumn(
[](ArrowSchema* schema) {
Expand Down

0 comments on commit 5f3350e

Please sign in to comment.