HG Data Query (SQL)
hg_data_query — execute / run SQL SELECT queries against the HG Insights data warehouse and get rows back. If you instead have a plain-English question and want the data (not the SQL), use market_data_agent, which resolves entities, writes and runs the query for you, and returns the result set as an artifact. Call the hg_catalog tool first to discover available tables and columns before writing queries. Queries must be SELECT-only. Returns rows, column names, row count, and credits consumed. Credits are charged on rows returned (max_rows caps the charge).
For 'how many companies run X' call search_companies (it matches Platform Market Analyzer); PREFER it for product/vendor/category and firmographic filters too. If you must count in SQL, use the install_localized pattern in the query param and state level + window in the answer. Use hg_data_query only for multi-table joins, time-series, or aggregations search_companies cannot express.
CONSTRAINTS: SELECT * rejected — list explicit columns.
KEY COLUMNS: company_locations(cl): name, country_name, country_code, employees_min, employees_max, company_id, url_id, is_gp. install_localized(il): product_id, product_name, vendor_name, category_leaf_name, url_id, country_code, last_verified_at — NO category_id. Count companies: join ON (url_id, country_code), cl.is_gp = true, il.last_verified_at >= today() - INTERVAL 24 MONTH, is_platform_permissible on both.
TAM: call get_vendor_information for product IDs, then filter install_localized by product_id. See query param for worked examples.
Credits
1 — 1 per row returned. See the full credit table for how AI Credits work.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
query Required | string | - | A single read-only SQL statement to run against the HG data warehouse. Must start with SELECT or WITH; SELECT * and any write/DDL (INSERT/UPDATE/DELETE/DROP) are rejected. Use exact table/column names from hg_catalog. Examples — (1) "How many Corporate Parents run ServiceNow CSM?" (the Platform Market Analyzer definition: Corporate Parents, product detected in the last 24 months) → call get_vendor_information(vendorName: "ServiceNow") for product IDs, then: SELECT uniqExact(cl.company_id) AS corporate_parents FROM install_localized il JOIN company_locations cl ON cl.url_id = il.url_id AND cl.country_code = il.country_code WHERE il.product_id IN (<product_ids>) AND il.is_platform_permissible = true AND cl.is_platform_permissible = true AND cl.is_gp = true AND il.last_verified_at >= today() - INTERVAL 24 MONTH LIMIT 1. Answer with the level and window, e.g. '787 Corporate Parents with ServiceNow CSM detected in the last 24 months'. (2) "Companies running a SIEM that's not Splunk" (competitive displacement) → call get_vendor_information for Splunk product IDs, then: SELECT DISTINCT cl.company_id, cl.name FROM install_localized il JOIN company_locations cl ON cl.url_id = il.url_id AND cl.country_code = il.country_code WHERE il.category_leaf_name IN (SELECT DISTINCT category_leaf_name FROM install_localized WHERE product_id IN (<splunk_product_ids>) AND is_platform_permissible = true AND last_verified_at >= today() - INTERVAL 24 MONTH) AND il.product_id NOT IN (<splunk_product_ids>) AND il.is_platform_permissible = true AND cl.is_platform_permissible = true AND cl.is_gp = true AND il.last_verified_at >= today() - INTERVAL 24 MONTH LIMIT 1000. The category subquery derives Splunk's categories from install_localized itself — get_vendor_information returns product_id/product_name only, not category_leaf_name. |
max_rows | integer | 1000 | Row cap for the result set (default: 1000, max: 10000). Credits are charged on rows returned, so max_rows caps the charge. |
Required Integrations
This tool is only available when your organization has the following integration configured in the HG Insights Integrations settings:
- HG Insights (
hginsights)
Use Cases
- Run a custom aggregation or cross-table join no purpose-built HG tool can express — call hg_catalog first for exact table/column names
- Compute TAM: count Corporate Parents (cl.is_gp) running a product in the last 24 months — install_localized joined to company_locations on (url_id, country_code), is_platform_permissible on both
- Competitive displacement: companies in a category that do NOT run a given vendor (category IN <subquery> AND product_id NOT IN <ids>)
- Time-series or trend rollups across warehouse tables not exposed by a specific tool
- Ad hoc warehouse exploration once you know the exact tables and columns from hg_catalog
Example Usage
Count Corporate Parents running a product in the last 24 months (Platform Market Analyzer definition; product IDs from get_vendor_information)
{
"tool": "hg_data_query",
"arguments": {
"query": "SELECT uniqExact(cl.company_id) AS corporate_parents FROM install_localized il JOIN company_locations cl ON cl.url_id = il.url_id AND cl.country_code = il.country_code WHERE il.product_id IN (1234, 5678) AND il.is_platform_permissible = true AND cl.is_platform_permissible = true AND cl.is_gp = true AND il.last_verified_at >= today() - INTERVAL 24 MONTH LIMIT 1"
}
}
Competitive displacement: SIEM installs that are not Splunk
{
"tool": "hg_data_query",
"arguments": {
"query": "SELECT DISTINCT cl.company_id, cl.name FROM install_localized il JOIN company_locations cl ON cl.url_id = il.url_id AND cl.country_code = il.country_code WHERE il.category_leaf_name IN (SELECT DISTINCT category_leaf_name FROM install_localized WHERE product_id IN (1234, 5678) AND is_platform_permissible = true AND last_verified_at >= today() - INTERVAL 24 MONTH) AND il.product_id NOT IN (1234, 5678) AND il.is_platform_permissible = true AND cl.is_platform_permissible = true AND cl.is_gp = true AND il.last_verified_at >= today() - INTERVAL 24 MONTH LIMIT 500",
"max_rows": 500
}
}
Response Format
| Field | Type | Description |
|---|---|---|
rows | array | Rows returned by the query. |
columns | array | Column names returned by the query. |
row_count | number | Number of rows returned. |
credits_consumed | number | Credits consumed by this query. |
Related Tools
hg_catalog, search_companies, company_technographic, get_vendor_information, company_install_time_series