# Chalk SQL Reference: Table-Valued Functions
source: https://docs.chalk.ai/chalksql-docs#section-table-valued-functions

## `datasource_query(datasource_name, query)`
source: https://docs.chalk.ai/chalksql-docs#datasource_query

Runs a SQL `query` directly against a registered datasource and returns the datasource result as a table. Use this when the SQL should be interpreted by the datasource dialect instead of the Chalk SQL dialect.

**Parameters**

- `datasource_name`: `string`
  The name of the registered datasource to query.
- `query`: `string`
  The SQL `query` to execute against the datasource.

**Examples**

```sql
SELECT * FROM datasource_query('my_postgres', 'SELECT id, email FROM public.users LIMIT 10');
```
