# DynamoDB
source: https://docs.chalk.ai/docs/dynamodb

## Integrate with DynamoDB.

Chalk supports DynamoDB as a natively accelerated SQL source. After establishing the integration,
you will be able to query your DynamoDB instance through Chalk with PartiQL.

### Adding DynamoDB

By navigating to Integrations > Add a data source and selecting DynamoDB, you'll find a form where you can input information about your DynamoDB integration.
Note that the data source must be accessible by the IAM Role defined in your cluster deployment.

### Integration

Add your DynamoDB data source in a Python file and give it a name. This line is required for all DynamoDB
integrations. In this file, we'll also define a User feature class with a transaction_volume feature which will be
resolved with DynamoDB.

```
from chalk.features import features
from chalk.sql import DynamoDBSource

DynamoDBSource(name="user_data")  # required for Chalk to be aware of this source

@features
class User:
    id: str
    transaction_volume: float
    high_volume: bool = _.transaction_volume > 1000
```

Now, you are all set to use DynamoDB with SQL file resolvers:

```
-- type: online
-- resolves: User
-- source: user_data
SELECT
    id,
    TransactionVolume AS transaction_volume
FROM UserTable
```

This file resolves two features of the feature class User: User.transaction_volume and User.id.
When the User.transaction_volume feature is required (or if it's needed for computing a downstream feature
like User.high_volume), Chalk will execute the SQL query on your DynamoDB instance and
return the result.
The -- source: user_data comment tells Chalk to use the DynamoDBSource with the name user_data to resolve this
query.

### Chalk's DynamoDB Query Language

Chalk uses PartiQL to execute SQL queries on your DynamoDB connection. Chalk extends PartiQL to
support aliasing and limits: you can rename your result columns to match your feature names
and limit results. The above example demonstrates aliasing with TransactionVolume AS transaction_volume.

Chalk extends PartiQL with the following syntax:

```
--- Amazon PartiQL
SELECT expression  [, ...]
FROM table[.index]
[ WHERE condition ] [ ORDER BY key [DESC|ASC] , ...]

--- Chalk PartiQL
SELECT expression [AS alias] [, ...]
FROM table[.index]
[ WHERE condition ] [ ORDER BY key [DESC|ASC] , ...]
[ LIMIT limit ]
```

You can also use batch execution with
PartiQL
to retrieve multiple records in a single request via ChalkClient.query_bulk. Batch
execution is only supported for single table queries.





