feat(spanner): implement search_catalog tool and add docs/tests#3140
feat(spanner): implement search_catalog tool and add docs/tests#3140anikasharma03 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the search_catalog tool for Cloud Spanner, enabling searches for data assets in Knowledge Catalog (Dataplex). The changes include the tool implementation, documentation, and updates to the Spanner source to support Dataplex client initialization with OAuth token caching. Review feedback highlights a style guide violation in the documentation title format, suggests improving the ExtractType logic for better LLM context, and identifies a redundant nil check on the search iterator.
| @@ -0,0 +1,65 @@ | |||
| --- | |||
| title: "spanner-search-catalog" | |||
There was a problem hiding this comment.
According to the repository rules, the title in the YAML frontmatter for tool documentation files should use kebab-case for the tool name, followed by ' Tool'.
| title: "spanner-search-catalog" | |
| title: "spanner-search-catalog Tool" |
References
- For tool documentation files, the title in the YAML frontmatter should use kebab-case for the tool name, followed by ' Tool'.
| func ExtractType(resourceString string) string { | ||
| lastIndex := strings.LastIndex(resourceString, "/") | ||
| if lastIndex == -1 { | ||
| return resourceString | ||
| } | ||
| return typeMap[resourceString[lastIndex+1:]] | ||
| } |
There was a problem hiding this comment.
The ExtractType function returns an empty string if the entry type suffix is not found in the typeMap. This might be confusing for the LLM. It would be better to return the original suffix or a default value like 'UNKNOWN' when a mapping is missing.
func ExtractType(resourceString string) string {
lastIndex := strings.LastIndex(resourceString, "/")
if lastIndex == -1 {
return resourceString
}
suffix := resourceString[lastIndex+1:]
if val, ok := typeMap[suffix]; ok {
return val
}
return suffix
}| if it == nil { | ||
| return nil, util.NewClientServerError(fmt.Sprintf("failed to create search entries iterator for project %q", source.ProjectID()), http.StatusInternalServerError, nil) | ||
| } |
8ec782a to
6c6997a
Compare
TanmayVartak
left a comment
There was a problem hiding this comment.
Thanks for adding this functionality to Spanner source.
| return s.UseClientOAuth | ||
| } | ||
|
|
||
| func (s *Source) GetCatalogClient(ctx context.Context, tokenString string) (*dataplexapi.CatalogClient, error) { |
There was a problem hiding this comment.
Can GetCatalogClient be part of utils shared across multiple data sources? Code is generic and nothing specific to Spanner.
| return resourceType | ||
| } | ||
|
|
||
| func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) { |
| DataplexEntry string | ||
| } | ||
|
|
||
| var typeMap = map[string]string{ |
There was a problem hiding this comment.
Apart from typeMap everything in this function is generic and may provide additional opportunity to move generic functionality under util. Consider base class "SearchCatalog(typeMap, )"
Description
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #<issue_number_goes_here>