create_hg_maxcompute_foreign_table
Enable efficient querying of MaxCompute data by creating a foreign table in Hologres, specifying project, schema, and table details for seamless integration.
Instructions
Create a MaxCompute foreign table in Hologres database to accelerate queries on MaxCompute data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| local_schema | No | The local schema name in Hologres (optional, default: 'public') | public |
| maxcompute_project | Yes | The MaxCompute project name (required) | |
| maxcompute_schema | No | The MaxCompute schema name (optional, default: 'default') | default |
| maxcompute_tables | Yes | The MaxCompute table names (required) |
Implementation Reference
- Executes the tool by validating inputs, constructing an IMPORT FOREIGN SCHEMA SQL statement to create MaxCompute foreign tables in Hologres, and passing it to handle_call_tool for execution.elif name == "create_hg_maxcompute_foreign_table": maxcompute_project = arguments.get("maxcompute_project") maxcompute_schema = arguments.get("maxcompute_schema", "default") maxcompute_tables = arguments.get("maxcompute_tables") local_schema = arguments.get("local_schema", "public") if not all([maxcompute_project, maxcompute_tables]): raise ValueError("maxcompute_project and maxcompute_tables are required") maxcompute_table_list = ", ".join(maxcompute_tables) # 修复 SQL 语句,确保正确拼接项目名称和 schema query = f""" IMPORT FOREIGN SCHEMA "{maxcompute_project}#{maxcompute_schema}" LIMIT TO ({maxcompute_table_list}) FROM SERVER odps_server INTO {local_schema}; """
- Defines the input schema for the tool, specifying parameters like maxcompute_project, maxcompute_schema, maxcompute_tables, and local_schema with types, descriptions, defaults, and required fields.inputSchema={ "type": "object", "properties": { "maxcompute_project": { "type": "string", "description": "The MaxCompute project name (required)" }, "maxcompute_schema": { "type": "string", "default": "default", "description": "The MaxCompute schema name (optional, default: 'default')" }, "maxcompute_tables": { "type": "array", "items": { "type": "string" }, "description": "The MaxCompute table names (required)" }, "local_schema": { "type": "string", "default": "public", "description": "The local schema name in Hologres (optional, default: 'public')" } }, "required": ["maxcompute_project", "maxcompute_tables"] }
- src/hologres_mcp_server/server.py:471-501 (registration)Registers the tool in the list_tools() function with its name, description, and input schema.Tool( name="create_hg_maxcompute_foreign_table", description="Create a MaxCompute foreign table in Hologres database to accelerate queries on MaxCompute data.", inputSchema={ "type": "object", "properties": { "maxcompute_project": { "type": "string", "description": "The MaxCompute project name (required)" }, "maxcompute_schema": { "type": "string", "default": "default", "description": "The MaxCompute schema name (optional, default: 'default')" }, "maxcompute_tables": { "type": "array", "items": { "type": "string" }, "description": "The MaxCompute table names (required)" }, "local_schema": { "type": "string", "default": "public", "description": "The local schema name in Hologres (optional, default: 'public')" } }, "required": ["maxcompute_project", "maxcompute_tables"] } ),