You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixesgoogleapis#861
This PR adds support for DuckDB which is a free, open-source, embedded,
in-process, relational database management system (RDBMS) designed for
analytical processing (OLAP)
---------
Co-authored-by: Averi Kitsch <akitsch@google.com>
DuckDB is an in-process SQL OLAP database management system designed for analytical query processing.
8
+
---
9
+
10
+
## About
11
+
12
+
[DuckDB](https://duckdb.org/) is an embedded analytical database management system that runs in-process with the client application. It is optimized for analytical workloads, providing high performance for complex queries with minimal setup.
13
+
14
+
DuckDB has the following notable characteristics:
15
+
16
+
- In-process, serverless database engine
17
+
- Supports complex SQL queries for analytical processing
18
+
- Can operate on in-memory or persistent storage
19
+
- Zero-configuration - no external dependencies or server setup required
20
+
- Highly optimized for columnar data storage and query execution
21
+
22
+
For more details, refer to the [DuckDB Documentation](https://duckdb.org/).
23
+
24
+
## Available Tools
25
+
-[`duckdb-sql`](../tools/duckdb/duckdb-sql.md)
26
+
Execute pre-defined prepared SQL queries in DuckDB.
27
+
28
+
## Requirements
29
+
30
+
### Database File
31
+
32
+
To use DuckDB, you can either:
33
+
34
+
- Specify a file path for a persistent database stored on the filesystem
For a complete list of available configuration options, refer to the [DuckDB Configuration Documentation](https://duckdb.org/docs/stable/configuration/overview.html#local-configuration-options).
71
+
72
+
73
+
For more details on the Go implementation, see the [go-duckdb package documentation](https://pkg.go.dev/github.com/scottlepp/go-duckdb#section-readme).
Execute SQL statements against a DuckDB database using the DuckDB SQL tools configuration.
7
+
aliases:
8
+
- /resources/tools/duckdb-sql
9
+
---
10
+
11
+
## About
12
+
13
+
A `duckdb-sql` tool executes a pre-defined SQL statement against a [DuckDB](https://duckdb.org/) database. It is compatible with any DuckDB source configuration as defined in the [DuckDB source documentation](../../sources/duckdb.md).
14
+
15
+
The specified SQL statement is executed as a prepared statement, and parameters are inserted according to their position: e.g., `$1` is the first parameter, `$2` is the second, and so on. If template parameters are included, they are resolved before execution of the prepared statement.
16
+
17
+
DuckDB's SQL dialect closely follows the conventions of the PostgreSQL dialect, with a few exceptions listed in the [DuckDB PostgreSQL Compatibility documentation](https://duckdb.org/docs/stable/sql/dialect/postgresql_compatibility.html). For an introduction to DuckDB's SQL dialect, refer to the [DuckDB SQL Introduction](https://duckdb.org/docs/stable/sql/introduction).
18
+
19
+
### Concepts
20
+
21
+
DuckDB is a relational database management system (RDBMS). Data is stored in relations (tables), where each table is a named collection of rows. Each row in a table has the same set of named columns, each with a specific data type. Tables are stored within schemas, and a collection of schemas constitutes the entire database.
22
+
23
+
For more details, see the [DuckDB SQL Introduction](https://duckdb.org/docs/stable/sql/introduction).
24
+
25
+
## Example
26
+
27
+
> **Note:** This tool uses parameterized queries to prevent SQL injections. Query parameters can be used as substitutes for arbitrary expressions but cannot be used for identifiers, column names, table names, or other parts of the query.
28
+
29
+
```yaml
30
+
tools:
31
+
search-users:
32
+
kind: duckdb-sql
33
+
source: my-duckdb
34
+
description: Search users by name and age
35
+
statement: SELECT * FROM users WHERE name LIKE $1 AND age >= $2
36
+
parameters:
37
+
- name: name
38
+
type: string
39
+
description: The name to search for
40
+
- name: min_age
41
+
type: integer
42
+
description: Minimum age
43
+
```
44
+
45
+
## Example with Template Parameters
46
+
47
+
> **Note:** Template parameters allow direct modifications to the SQL statement, including identifiers, column names, and table names, which makes them more vulnerable to SQL injections. Using basic parameters (see above) is recommended for performance and safety. For more details, see the [templateParameters](../#template-parameters) section.
48
+
49
+
```yaml
50
+
tools:
51
+
list_table:
52
+
kind: duckdb-sql
53
+
source: my-duckdb
54
+
statement: |
55
+
SELECT * FROM {{.tableName}};
56
+
description: |
57
+
Use this tool to list all information from a specific table.
| source | string | true | Name of the DuckDB source configuration (see [DuckDB source documentation](../../sources/duckdb.md)). |
76
+
| description | string | true | Description of the tool that is passed to the LLM. |
77
+
| statement | string | true | The SQL statement to execute. |
78
+
| authRequired | []string | false | List of authentication requirements for the tool (if any). |
79
+
| parameters | [parameters](../#specifying-parameters) | false | List of parameters that will be inserted into the SQL statement |
80
+
| templateParameters | [templateParameters](../#template-parameters) | false | List of template parameters that will be inserted into the SQL statement before executing the prepared statement. |
0 commit comments