| 2107 | void exportArrayToArrowSchema( |
| 2108 | const ArrayVector& arrays, |
| 2109 | ArrowSchema& arrowSchema, |
| 2110 | const ArrowOptions& options, |
| 2111 | BoltToArrowSchemaBridgeHolder* bridgeHolder, |
| 2112 | memory::MemoryPool* pool) { |
| 2113 | auto& type = arrays.type(); |
| 2114 | auto child = std::make_unique<ArrowSchema>(); |
| 2115 | BOLT_CHECK( |
| 2116 | arrays.elements()->type()->equivalent(*type->asArray().elementType()), |
| 2117 | "array vector child type: {}, type child: {}", |
| 2118 | arrays.elements()->type()->toString(), |
| 2119 | type->asArray().elementType()->toString()); |
| 2120 | exportToArrow(arrays.elements(), *child, options, {}, pool); |
| 2121 | // Name is required, and "item" is the default name used in arrow itself. |
| 2122 | child->name = "item"; |
| 2123 | bridgeHolder->setChildAtIndex(0, std::move(child), arrowSchema); |
| 2124 | } |
| 2125 | |
| 2126 | void exportVariantToArrowSchema( |
| 2127 | const VariantVector& variant, |
| 2128 | ArrowSchema& arrowSchema, |
| 2129 | const ArrowOptions& options, |
| 2130 | BoltToArrowSchemaBridgeHolder* bridgeHolder, |
| 2131 | memory::MemoryPool* pool) { |
| 2132 | auto numChildren = variant.childrenSize(); |
| 2133 | bridgeHolder->childrenRaw.resize(numChildren); |
| 2134 | bridgeHolder->childrenOwned.resize(numChildren); |
| 2135 | for (column_index_t i = 0; i < numChildren; ++i) { |
| 2136 | auto child = std::make_unique<ArrowSchema>(); |
| 2137 | exportToArrow(variant.childAt(i), *child, options, {}, pool); |
| 2138 | child->name = (i == 0) ? "value" : "metadata"; |
| 2139 | bridgeHolder->setChildAtIndex(i, std::move(child), arrowSchema); |
| 2140 | } |
| 2141 | setArrowMetadataEntry( |
| 2142 | arrowSchema, |
| 2143 | *bridgeHolder, |
| 2144 | kArrowExtensionNameKey, |
| 2145 | kSparkVariantExtensionName); |
| 2146 | } |
| 2147 | |
| 2148 | void exportRowToArrowSchema( |
| 2149 | const RowVector& rows, |
| 2150 | ArrowSchema& arrowSchema, |
| 2151 | const ArrowOptions& options, |
| 2152 | BoltToArrowSchemaBridgeHolder* bridgeHolder, |
| 2153 | const std::vector<std::string>& fieldNames, |
| 2154 | memory::MemoryPool* pool) { |
| 2155 | auto& type = rows.type(); |
| 2156 | auto numChildren = rows.childrenSize(); |
| 2157 | bridgeHolder->childrenRaw.resize(numChildren); |
| 2158 | bridgeHolder->childrenOwned.resize(numChildren); |
| 2159 | |
| 2160 | // Hold the shared_ptr so we can set the ArrowSchema.name pointer to its |
| 2161 | // internal `name` string. |
| 2162 | bridgeHolder->rowType = std::static_pointer_cast<const RowType>(type); |
| 2163 | |
| 2164 | arrowSchema.children = bridgeHolder->childrenRaw.data(); |
| 2165 | arrowSchema.n_children = numChildren; |
| 2166 |
no test coverage detected