mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-11 16:38:15 -05:00
feat(prebuilt/mysql): Add a new tool to show query plan of a given query in MySQL (#1474)
## Description Adds a read-only MySQL prebuilt tool, `get_query_plan`, that returns the optimizer’s estimated plan for a single SQL statement using `EXPLAIN FORMAT JSON`. ## PR Checklist --- > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Make sure to add `!` if this involve a breaking change --------- Co-authored-by: Averi Kitsch <akitsch@google.com>
This commit is contained in:
@@ -1429,7 +1429,7 @@ func TestPrebuiltTools(t *testing.T) {
|
||||
wantToolset: server.ToolsetConfigs{
|
||||
"cloud_sql_mysql_database_tools": tools.ToolsetConfig{
|
||||
Name: "cloud_sql_mysql_database_tools",
|
||||
ToolNames: []string{"execute_sql", "list_tables"},
|
||||
ToolNames: []string{"execute_sql", "get_query_plan", "list_tables"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1469,7 +1469,7 @@ func TestPrebuiltTools(t *testing.T) {
|
||||
wantToolset: server.ToolsetConfigs{
|
||||
"mysql_database_tools": tools.ToolsetConfig{
|
||||
Name: "mysql_database_tools",
|
||||
ToolNames: []string{"execute_sql", "list_tables"},
|
||||
ToolNames: []string{"execute_sql", "get_query_plan", "list_tables"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -99,6 +99,7 @@ See guides, [Connect from your IDE](../how-to/connect-ide/_index.md), for detail
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `get_query_plan`: Provides information about how MySQL executes a SQL statement.
|
||||
|
||||
## Cloud SQL for MySQL Observability
|
||||
|
||||
@@ -255,6 +256,7 @@ See guides, [Connect from your IDE](../how-to/connect-ide/_index.md), for detail
|
||||
* **Tools:**
|
||||
* `execute_sql`: Executes a SQL query.
|
||||
* `list_tables`: Lists tables in the database.
|
||||
* `get_query_plan`: Provides information about how MySQL executes a SQL statement.
|
||||
|
||||
## OceanBase
|
||||
|
||||
|
||||
@@ -27,6 +27,17 @@ tools:
|
||||
kind: mysql-execute-sql
|
||||
source: cloud-sql-mysql-source
|
||||
description: Use this tool to execute SQL.
|
||||
get_query_plan:
|
||||
kind: mysql-sql
|
||||
source: cloud-sql-mysql-source
|
||||
description: "Provide information about how MySQL executes a SQL statement. Common use cases include: 1) analyze query plan to improve its performance, and 2) determine effectiveness of existing indexes and evalueate new ones."
|
||||
statement: |
|
||||
EXPLAIN FORMAT=JSON {{.sql_statement}};
|
||||
templateParameters:
|
||||
- name: sql_statement
|
||||
type: string
|
||||
description: "the SQL statement to explain"
|
||||
required: true
|
||||
list_tables:
|
||||
kind: mysql-list-tables
|
||||
source: cloud-sql-mysql-source
|
||||
@@ -35,4 +46,5 @@ tools:
|
||||
toolsets:
|
||||
cloud_sql_mysql_database_tools:
|
||||
- execute_sql
|
||||
- get_query_plan
|
||||
- list_tables
|
||||
|
||||
@@ -31,6 +31,17 @@ tools:
|
||||
kind: mysql-execute-sql
|
||||
source: mysql-source
|
||||
description: Use this tool to execute SQL.
|
||||
get_query_plan:
|
||||
kind: mysql-sql
|
||||
source: mysql-source
|
||||
description: "Provide information about how MySQL executes a SQL statement. Common use cases include: 1) analyze query plan to improve its performance, and 2) determine effectiveness of existing indexes and evalueate new ones."
|
||||
statement: |
|
||||
EXPLAIN FORMAT=JSON {{.sql_statement}};
|
||||
templateParameters:
|
||||
- name: sql_statement
|
||||
type: string
|
||||
description: "the SQL statement to explain"
|
||||
required: true
|
||||
list_tables:
|
||||
kind: mysql-list-tables
|
||||
source: mysql-source
|
||||
@@ -39,4 +50,5 @@ tools:
|
||||
toolsets:
|
||||
mysql_database_tools:
|
||||
- execute_sql
|
||||
- get_query_plan
|
||||
- list_tables
|
||||
|
||||
Reference in New Issue
Block a user