bigtable-sql

A “bigtable-sql” tool executes a pre-defined SQL statement against a Google Cloud Bigtable instance.

About

A bigtable-sql tool executes a pre-defined SQL statement against a Bigtable instance. It’s compatible with any of the following sources:

GoogleSQL

Bigtable supports SQL queries. The integration with Toolbox supports googlesql dialect, the specified SQL statement is executed as a data manipulation language (DML) statements, and specified parameters will inserted according to their name: e.g. @name.

Note: This tool uses parameterized queries to prevent SQL injections. Query parameters can be used as substitutes for arbitrary expressions. Parameters cannot be used as substitutes for identifiers, column names, table names, or other parts of the query.

Example

tools:
 search_user_by_id_or_name:
    kind: bigtable-sql
    source: my-bigtable-instance
    statement: |
      SELECT 
        TO_INT64(cf[ 'id' ]) as id, 
        CAST(cf[ 'name' ] AS string) as name, 
      FROM 
        mytable 
      WHERE 
        TO_INT64(cf[ 'id' ]) = @id 
        OR CAST(cf[ 'name' ] AS string) = @name;
    description: |
      Use this tool to get information for a specific user.
      Takes an id number or a name and returns info on the user.

      Example:
      {{
          "id": 123,
          "name": "Alice",
      }}
    parameters:
      - name: id
        type: integer
        description: User ID
      - name: name
        type: string
        description: Name of the user

Reference

fieldtyperequireddescription
kindstringtrueMust be “bigtable-sql”.
sourcestringtrueName of the source the SQL should execute on.
descriptionstringtrueDescription of the tool that is passed to the LLM.
statementstringtrueSQL statement to execute on.
parametersparametersfalseList of parameters that will be inserted into the SQL statement.

Tips

  • Bigtable Studio is a useful to explore and manage your Bigtable data. If you’re unfamiliar with the query syntax, Query Builder lets you build a query, run it against a table, and then view the results in the console.
  • Some Python libraries limit the use of underscore columns such as _key. A workaround would be to leverage Bigtable Logical Views to rename the columns.
Last modified May 28, 2025: docs: add note to tools (#608) (1bf6003e)