| 15 | }; |
| 16 | |
| 17 | TEST_F(ArrowTableFunctionTest, CreateArrowTable) { |
| 18 | // Create simple test data |
| 19 | std::vector<int32_t> intData = {1, 2, 3}; |
| 20 | |
| 21 | // Create Arrow schema |
| 22 | ArrowSchemaWrapper schema; |
| 23 | createStructSchema(&schema, 1); |
| 24 | createSchema<int32_t>(schema.children[0], "id"); |
| 25 | |
| 26 | // Create Arrow array |
| 27 | ArrowArray array; |
| 28 | array.length = intData.size(); |
| 29 | array.null_count = 0; |
| 30 | array.offset = 0; |
| 31 | array.n_buffers = 1; |
| 32 | array.n_children = 1; |
| 33 | array.buffers = static_cast<const void**>(malloc(sizeof(void*))); |
| 34 | array.buffers[0] = nullptr; |
| 35 | array.children = static_cast<ArrowArray**>(malloc(sizeof(ArrowArray*))); |
| 36 | array.children[0] = static_cast<ArrowArray*>(malloc(sizeof(ArrowArray))); |
| 37 | createInt32Array(array.children[0], intData); |
| 38 | array.dictionary = nullptr; |
| 39 | array.release = [](ArrowArray* arr) { |
| 40 | if (arr->children) { |
| 41 | for (int64_t i = 0; i < arr->n_children; i++) { |
| 42 | if (arr->children[i]->release) { |
| 43 | arr->children[i]->release(arr->children[i]); |
| 44 | } |
| 45 | free(arr->children[i]); |
| 46 | } |
| 47 | free(arr->children); |
| 48 | } |
| 49 | if (arr->buffers) { |
| 50 | free(const_cast<void**>(arr->buffers)); |
| 51 | } |
| 52 | arr->release = nullptr; |
| 53 | }; |
| 54 | array.private_data = nullptr; |
| 55 | |
| 56 | // Test that we can create arrays with Arrow C Data Interface |
| 57 | EXPECT_EQ(array.length, 3); |
| 58 | EXPECT_EQ(array.n_children, 1); |
| 59 | EXPECT_STREQ(schema.children[0]->name, "id"); |
| 60 | |
| 61 | // Cleanup |
| 62 | if (schema.release) |
| 63 | schema.release(&schema); |
| 64 | if (array.release) |
| 65 | array.release(&array); |
| 66 | } |
| 67 | |
| 68 | TEST_F(ArrowTableFunctionTest, CreateArrowTableMultipleColumns) { |
| 69 | // Create test data with multiple columns |
nothing calls this directly
no test coverage detected