Skip to content

Query

The Query agent is a streamlined SQL assistant for querying databases associated with data products. It translates natural language questions into SQL queries and returns data-driven answers.

The agent follows this workflow:

  1. Receives a natural language question from the user
  2. Uses the Get Data Schema tool to understand available tables and columns
  3. Generates and executes SQL queries using the SQL Execution tool
  4. Analyzes results and may refine queries as needed
  5. Returns the final consolidated results in a single table

Required:

  • message (string): The natural language question or request to send to the agent
  • data_product_id (string): The ID of the data product to query

The agent produces a series of thinking, tool call, tool return, and text blocks as it works through the user request. The final message, assuming no errors, is a string which addresses the user’s request.

The agent has access to two tools:

Retrieves the schema for tables in the data product. Optionally supports semantic search of sample values.

Key parameters:

  • data_product_id: The data product to get schema for
  • query: Optional semantic search query for sample values

Executes SQL queries against the data product’s database. The tool automatically handles result serialization and may limit rows/columns for very large results.

Key parameters:

  • data_product_id: The data product to query
  • sql: The SQL query to execute
  • result_table_name: A semantic name for the result table
  • The agent always uses result tables from executed queries to answer questions (never synthesizes data)
  • For complex questions, it executes a final consolidated query to return all results in a single table
  • Results are returned as tables, not markdown formatted text
  • This agent is optimized for query execution without visualization capabilities

The Query agent is similar to the Data Product Query agent but:

  • Does not include chart generation capabilities
  • Focuses purely on SQL execution and data retrieval
  • Lighter weight for straightforward querying tasks

For visualization needs, use the Data Product Query agent instead.