| 16 | }; |
| 17 | |
| 18 | TEST_F(ArrowNodeTableTest, CreateArrowTableFromVectors) { |
| 19 | // Create test data |
| 20 | std::vector<int32_t> intData = {1, 2, 3, 4, 5}; |
| 21 | std::vector<std::string> stringData = {"a", "b", "c", "d", "e"}; |
| 22 | |
| 23 | // Create Arrow schema with 2 fields |
| 24 | ArrowSchema schema; |
| 25 | createStructSchema(&schema, 2); |
| 26 | createSchema<int32_t>(schema.children[0], "int_col"); |
| 27 | createSchema<std::string>(schema.children[1], "string_col"); |
| 28 | |
| 29 | // Create Arrow array with 2 children |
| 30 | ArrowArray array; |
| 31 | array.length = intData.size(); |
| 32 | array.null_count = 0; |
| 33 | array.offset = 0; |
| 34 | array.n_buffers = 1; |
| 35 | array.n_children = 2; |
| 36 | array.buffers = static_cast<const void**>(malloc(sizeof(void*))); |
| 37 | array.buffers[0] = nullptr; |
| 38 | array.children = static_cast<ArrowArray**>(malloc(sizeof(ArrowArray*) * 2)); |
| 39 | for (int i = 0; i < 2; i++) { |
| 40 | array.children[i] = static_cast<ArrowArray*>(malloc(sizeof(ArrowArray))); |
| 41 | } |
| 42 | createInt32Array(array.children[0], intData); |
| 43 | createStringArray(array.children[1], stringData); |
| 44 | array.dictionary = nullptr; |
| 45 | array.release = [](ArrowArray* arr) { |
| 46 | if (arr->children) { |
| 47 | for (int64_t i = 0; i < arr->n_children; i++) { |
| 48 | if (arr->children[i]->release) { |
| 49 | arr->children[i]->release(arr->children[i]); |
| 50 | } |
| 51 | free(arr->children[i]); |
| 52 | } |
| 53 | free(arr->children); |
| 54 | } |
| 55 | if (arr->buffers) { |
| 56 | free(const_cast<void**>(arr->buffers)); |
| 57 | } |
| 58 | arr->release = nullptr; |
| 59 | }; |
| 60 | array.private_data = nullptr; |
| 61 | |
| 62 | // Verify properties |
| 63 | EXPECT_EQ(array.length, 5); |
| 64 | EXPECT_EQ(array.n_children, 2); |
| 65 | EXPECT_STREQ(schema.children[0]->name, "int_col"); |
| 66 | EXPECT_STREQ(schema.children[1]->name, "string_col"); |
| 67 | |
| 68 | // Cleanup |
| 69 | if (schema.release) |
| 70 | schema.release(&schema); |
| 71 | if (array.release) |
| 72 | array.release(&array); |
| 73 | } |
| 74 | |
| 75 | TEST_F(ArrowNodeTableTest, ArrowTableTypeConversions) { |
nothing calls this directly
no test coverage detected