Customer Data Query
Run a read-only SQL SELECT against the ORG'S OWN connected Snowflake data warehouse (the customer's data — e.g. their CRM accounts, opportunities, product usage — NOT HG Insights' market data). Use this when you already know the exact table and column names and need to read, filter, aggregate, or join the org's own rows to answer a question. This is the final step of the customer-data flow: discover → explore → query. The statement must start with SELECT or WITH. It is validated as read-only (no INSERT/UPDATE/DELETE/DDL) and is scoped to the single schema configured on the Snowflake connection — fully-qualified references outside that schema are rejected. TABLE() and IDENTIFIER() functions are not supported; use direct table references. A row limit and a 30s timeout are enforced. Do NOT use this when you don't yet know the schema, tables, or columns — run customer_data_discover to auto-map the schema, then customer_data_explore to list tables/columns and sample rows, before writing SQL here. Do NOT use this to query HG Insights’ market/technographic/firmographic warehouse — use hg_data_query for that.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | ❌ No | SELECT 1 | Read-only SQL to run against the org's own Snowflake schema. Must start with SELECT or WITH; INSERT/UPDATE/DELETE/DDL are rejected. All table references must resolve to the single configured schema (use bare or configured-schema-qualified table names from customer_data_explore). TABLE() and IDENTIFIER() are unsupported — reference tables directly. |
limit | integer | ❌ No | 100 | Hard cap on rows returned, enforced on top of any LIMIT in the SQL (default: 100, max: 10000). Lower it for wide tables to keep the response small. |
Required Integrations
snowflake
Use Cases
- Read specific rows from the org's own Snowflake tables once the table and column names are known
- Aggregate the org's own data (counts, sums, averages) to answer a business question
- Filter the org's accounts, opportunities, or usage records by a WHERE clause
- Join two tables in the org's configured schema on a shared key
- Return the top-N rows ordered by a column from a table found via customer_data_explore
Example Usage
Count rows in a known table
{
"tool": "customer_data_query",
"arguments": {
"query": "SELECT COUNT(*) AS n FROM ACCOUNTS"
}
}
Filter and cap rows
{
"tool": "customer_data_query",
"arguments": {
"query": "SELECT name, arr FROM ACCOUNTS WHERE segment = 'Enterprise'",
"limit": 50
}
}
Aggregate with GROUP BY
{
"tool": "customer_data_query",
"arguments": {
"query": "SELECT stage, COUNT(*) AS deals FROM OPPORTUNITIES GROUP BY stage"
}
}
Related Tools
customer_data_discover, customer_data_explore, hg_data_query