getTableObjectSchema retrieves the ObjectSchema for a table/collection/index/container by name from the database config. This is the shared implementation for all document databases (CosmosDB containers, MongoDB collections, Elasticsearch indices).
(ctx context.Context, stores *store.Store, instanceID, databaseName, tableName string)
| 1337 | // by name from the database config. This is the shared implementation for all document |
| 1338 | // databases (CosmosDB containers, MongoDB collections, Elasticsearch indices). |
| 1339 | func getTableObjectSchema(ctx context.Context, stores *store.Store, instanceID, databaseName, tableName string) (*storepb.ObjectSchema, error) { |
| 1340 | dbMetadata, err := stores.GetDBSchema(ctx, &store.FindDBSchemaMessage{ |
| 1341 | Workspace: common.GetWorkspaceIDFromContext(ctx), |
| 1342 | InstanceID: instanceID, |
| 1343 | DatabaseName: databaseName, |
| 1344 | }) |
| 1345 | if err != nil { |
| 1346 | return nil, errors.Wrapf(err, "failed to get database schema: %q", databaseName) |
| 1347 | } |
| 1348 | |
| 1349 | if dbMetadata == nil { |
| 1350 | return nil, nil |
| 1351 | } |
| 1352 | |
| 1353 | for _, schema := range dbMetadata.GetConfig().GetSchemas() { |
| 1354 | for _, table := range schema.GetTables() { |
| 1355 | if table.GetName() == tableName { |
| 1356 | return table.GetObjectSchema(), nil |
| 1357 | } |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | return nil, nil |
| 1362 | } |
| 1363 | |
| 1364 | // objectSchemaHasSemanticTypes recursively checks if any node in the ObjectSchema has a semantic type set. |
| 1365 | func objectSchemaHasSemanticTypes(os *storepb.ObjectSchema) bool { |
no test coverage detected