Integrations
Integrate with DynamoDB.
Chalk supports DynamoDB as a SQL source.
Follow the AWS instructions to give Chalk access to application credentials for your AWS account. Chalk will use these credentials to access DynamoDB.
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="my_dynamo") # required for Chalk to be aware of this source
@features
class User:
id: str
transaction_volume: float
Now, you are all set to use DynamoDB with SQL file resolvers:
-- type: online
-- resolves: user
-- source: my_dynamo
SELECT
id,
TransactionVolume AS transaction_volume
FROM
UserTable
LIMIT 10
This file resolves the User.transaction_volume
feature. Please note that the --source: my_dynamo
line is necessary
and should match the name
provided to your DynamoDBSource
.
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.