lookupTableCandidates issues a second GetDatabaseMetadata call (no table filter) to build a list of candidate table names for a TABLE_NOT_FOUND error. Bounded by schemaCandidateFetchLimit per schema on the wire and schemaCandidateResultCap on the returned slice.
(ctx context.Context, resourceName, schemaFilter, missing string)
| 477 | // Bounded by schemaCandidateFetchLimit per schema on the wire and |
| 478 | // schemaCandidateResultCap on the returned slice. |
| 479 | func (s *Server) lookupTableCandidates(ctx context.Context, resourceName, schemaFilter, missing string) []string { |
| 480 | filter := buildMetadataFilter(schemaFilter, "") |
| 481 | metadata, err := s.fetchMetadata(ctx, resourceName, filter, int32(schemaCandidateFetchLimit)) |
| 482 | if err != nil || metadata == nil { |
| 483 | return nil |
| 484 | } |
| 485 | var candidates []string |
| 486 | for _, schema := range metadata.Schemas { |
| 487 | for _, t := range schema.Tables { |
| 488 | if tableNameMatches(t.Name, missing) { |
| 489 | candidates = append(candidates, t.Name) |
| 490 | if len(candidates) >= schemaCandidateResultCap { |
| 491 | return candidates |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | return candidates |
| 497 | } |
| 498 | |
| 499 | // tableNameMatches returns true if `name` is a plausible candidate for a typo of |
| 500 | // `missing`. A name matches if it contains the input as a (case-insensitive) |
no test coverage detected