| 1285 | } |
| 1286 | |
| 1287 | Status SchemaManifest::Make(const SchemaDescriptor* schema, |
| 1288 | const std::shared_ptr<const KeyValueMetadata>& metadata, |
| 1289 | const ArrowReaderProperties& properties, |
| 1290 | SchemaManifest* manifest) { |
| 1291 | SchemaTreeContext ctx; |
| 1292 | ctx.manifest = manifest; |
| 1293 | ctx.properties = properties; |
| 1294 | ctx.schema = schema; |
| 1295 | ctx.metadata = metadata; |
| 1296 | const GroupNode& schema_node = *schema->group_node(); |
| 1297 | manifest->descr = schema; |
| 1298 | manifest->schema_fields.resize(schema_node.field_count()); |
| 1299 | |
| 1300 | // Try to deserialize original Arrow schema |
| 1301 | RETURN_NOT_OK( |
| 1302 | GetOriginSchema(metadata, &manifest->schema_metadata, &manifest->origin_schema)); |
| 1303 | // Ignore original schema if it's not compatible with the Parquet schema |
| 1304 | if (manifest->origin_schema != nullptr && |
| 1305 | manifest->origin_schema->num_fields() != schema_node.field_count()) { |
| 1306 | manifest->origin_schema = nullptr; |
| 1307 | } |
| 1308 | |
| 1309 | for (int i = 0; i < static_cast<int>(schema_node.field_count()); ++i) { |
| 1310 | SchemaField* out_field = &manifest->schema_fields[i]; |
| 1311 | RETURN_NOT_OK(NodeToSchemaField(*schema_node.field(i), LevelInfo(), &ctx, |
| 1312 | /*parent=*/nullptr, out_field)); |
| 1313 | |
| 1314 | // TODO(wesm): as follow up to ARROW-3246, we should really pass the origin |
| 1315 | // schema (if any) through all functions in the schema reconstruction, but |
| 1316 | // I'm being lazy and just setting dictionary fields at the top level for |
| 1317 | // now |
| 1318 | if (manifest->origin_schema == nullptr) { |
| 1319 | continue; |
| 1320 | } |
| 1321 | |
| 1322 | auto& origin_field = manifest->origin_schema->field(i); |
| 1323 | RETURN_NOT_OK(ApplyOriginalMetadata(*origin_field, out_field)); |
| 1324 | } |
| 1325 | return Status::OK(); |
| 1326 | } |
| 1327 | |
| 1328 | } // namespace parquet::arrow |
nothing calls this directly
no test coverage detected