技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
query【数据与研究】Use when the user wants to query, analyze, or explore data through the Honeydew semantic layer. Covers structured queries and multi-step deep analysis.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Queries run against the workspace and branch set for the current session. Use get_session_workspace_and_branch to check the current context. If no workspace/branch is set, use list_workspaces, list_workspace_branches, and set_session_workspace_and_branch to select one. See the model-exploration skill for the full workspace/branch tool reference.
Honeydew provides three ways to query data through the semantic layer. Each method suits a different situation — pick the right one based on how well you understand the model and how complex the question is.
| Method | Tool | Best For |
|---|---|---|
| Structured query | get_data_from_fields / get_sql_from_fields | You know the exact fields. Deterministic, full control. |
| Deep analysis | ask_deep_analysis_question | Any natural language question — simple or complex, "why", multi-step, agentic. |
get_data_from_fields / get_sql_from_fields)Use when:
list_entities / get_entity)detailed_listings.price by detailed_listings.room_type"Do NOT use when:
How it works:
get_data_from_fields — executes the query and returns data rowsget_sql_from_fields — returns the generated SQL without executing (useful for review, debugging, or handing off to other tools)Both take the same field parameters.
ask_deep_analysis_question)Use when:
conversation_id)User asks a data question
│
├─► Do you know the exact field names?
│ │
│ ├─► YES → get_data_from_fields (structured, deterministic)
│ │ (or get_sql_from_fields to preview SQL without executing)
│ │
│ └─► NO → ask_deep_analysis_question (plain English, any complexity)
│
└─► Plain English question / investigation / "why" / trends?
└─► ask_deep_analysis_question
A structured query uses flat field parameters to define what data to retrieve:
attributes — dimensions to group by (columns in the output), e.g. ["entity.attribute_name"]metrics — aggregated measures (SUM, COUNT, AVG, etc.), e.g. ["entity.metric_name"]filters — row-level filters applied before aggregation, e.g. ["entity.field = 'value'"]order_by — sort order for results. Each entry MUST be a quoted string, as if it were a SQL identifier — e.g. ["\"entity.field\" ASC"]. Always wrap the field reference in double quotes inside the string.domain — optional domain name for query contextlimit — max rows to return (default: 100)offset — rows to skip (for pagination)All fields use entity.field_name syntax. Cross-entity fields are supported when relations exist.
Before building a query, discover the available fields:
list_entities — see all entitiesget_entity with entity name — see its attributes, metrics, and relationsget_field with entity and field name — get detailed info about a specific fieldlist_domains — see all available domains (useful before passing domain parameter)search_model with a keyword and search_mode (OR for broad discovery, EXACT for known names) — find fields across the modelSimple metric query — total count:
Call get_data_from_fields with:
metrics: ["detailed_listings.count"]Dimension breakdown — listings by room type:
Call get_data_from_fields with:
attributes: ["detailed_listings.room_type"]metrics: ["detailed_listings.count"]order_by: ["\"detailed_listings.count\" DESC"]Filtered query — only entire homes:
Call get_data_from_fields with:
attributes: ["detailed_listings.neighbourhood_cleansed"]metrics: ["detailed_listings.count"]filters: ["detailed_listings.room_type = 'Entire home/apt'"]order_by: ["\"detailed_listings.count\" DESC"]Cross-entity query — listings with host info:
Call get_data_from_fields with:
attributes: ["detailed_listings.room_type", "dim_host.host_is_superhost"]metrics: ["detailed_listings.count"]order_by: ["\"detailed_listings.count\" DESC"]Using aliases — rename fields or ad-hoc expressions:
You can alias any field or ad-hoc expression using AS "alias_name". This controls the column name in the output.
Call get_data_from_fields with:
attributes: ["detailed_listings.room_type"]metrics: ["detailed_listings.count AS \"total_listings\"", "AVG(detailed_listings.price) AS \"avg_price\""]order_by: ["\"total_listings\" DESC"]Once aliased, use the alias (not the original expression) in order_by.
Pagination — large result sets:
Call get_data_from_fields with:
attributes: (your fields)metrics: (your metrics)limit: 50 (max rows to return)offset: 100 (skip first 100 rows)Finding duplicate values:
Call get_data_from_fields with:
attributes: ["detailed_listings.host_name"]metrics: ["COUNT(detailed_listings.host_name)"]filters: ["COUNT(detailed_listings.host_name) > 1"]order_by: ["\"COUNT(detailed_listings.host_name)\" DESC"]This groups by the attribute, counts occurrences, and filters to only rows that appear more than once — surfacing duplicates.
SQL preview only:
Call get_sql_from_fields with the same field parameters to see the generated SQL without executing.
Filters use standard comparison expressions: =, >, <, IN (...), ILIKE, SEARCH(...), IS NULL, booleans, date ranges, and AND/OR combinations.
For the complete filter expression reference — including SEARCH, date handling, and type casting — see the filtering skill.
Call with:
question (required): the analysis questionagent (optional): agent name to use as analysis context — use list_agents to discover available agents and their associated domainsconversation_id (optional): ID from a previous deep analysis call, for follow-up questionsquestion: "Analyze the relationship between host response time and review scores. Are there significant patterns?"
agent: "my_agent"
Returns:
conversation_id for continuing the conversationAfter a successful ask_deep_analysis_question call, the response includes a ui_url field. Always display this URL to the user so they can view the full analysis in the Honeydew application.
Use conversation_id from the previous response to ask follow-up questions that build on the prior analysis:
question: "Now break this down by room type — does the pattern hold across all types?"
agent: "my_agent"
conversation_id: "<id from previous response>"
Simple natural language:
Complex analysis:
For complex tasks, combine methods in sequence:
list_entities / get_entity to understand the modelget_data_from_fields for precise, targeted queriesask_deep_analysis_question for root cause or trend analysisUser: "Help me understand pricing patterns for Airbnb listings."
list_entities → find detailed_listingsget_entity for detailed_listings → find price, room_type, neighbourhood_cleansedget_data_from_fields → price distribution by neighbourhood for Entire homes onlyask_deep_analysis_question → "What factors most influence listing price? Analyze correlations with room type, location, amenities, and reviews."Use the honeydew-docs MCP tools to search the Honeydew documentation when:
Search for topics like: "queries", "perspectives", "dynamic datasets", "parameters", "query API".
To retrieve the distinct (unique) values of a field, include it in attributes and add a count metric in metrics.
Use the entity's built-in count metric (e.g., entity.count) if available, or an ad-hoc count metric using COUNT(entity.field)
on the field whose distinct values you want — never use COUNT(*).
The metric forces aggregation, which groups by the attribute and returns one row per distinct value.
Example — distinct room types:
Call get_data_from_fields with:
attributes: ["detailed_listings.room_type"]metrics: ["COUNT(detailed_listings.room_type)"]order_by: ["\"COUNT(detailed_listings.room_type)\" DESC"]This returns each unique room_type along with its count, ordered by frequency. The count is a useful bonus — it tells you how common each value is — but the key point is that the query returns one row per distinct value.
This pattern is useful for:
list_entities / get_entity before building queries, so you reference real fieldsget_data_from_fields gives you full control and reproducible resultslimit and offset in get_data_from_fields to avoid overwhelming outputget_sql_from_fields to inspect the generated queryentity.field_name syntax in field parameters