Integrations
Integrate with Spanner.
Chalk supports Spanner as a natively accelerated SQL source.
Follow the GCP instructions to give Chalk access to application credentials for your GCP account. Chalk will use these credentials to access Spanner. On the dashboard, you can plug in the configuration for your Spanner database:
Add a Spanner integration. These parameters will also be available as environment variables.
Add your Spanner data source in a Python file and give it a name
. This line is required for all Spanner
integrations. In this file, we’ll also define a User
feature class with a transaction_volume
feature which will be
resolved with Spanner.
If you have only one Spanner connection that you’d like to add to Chalk, you do not need to specify any arguments to construct the source in your code.
from chalk.features import features
from chalk.sql import SpannerSource
spanner_source = SpannerSource()
@features
class User:
id: str
transaction_volume: float
from chalk.sql import SpannerSource
spanner_source_txns = SpannerSource(name="SPANNER_TRANSACTIONS")
spanner_source_marketing = SpannerSource(name="SPANNER_MARKETING")
Now, you are all set to use Spanner with SQL file resolvers.
-- type: online
-- resolves: User
-- source: SPANNER_TRANSACTIONS
SELECT
id,
TransactionVolume AS transaction_volume
FROM
UserTable
LIMIT 10
This file resolves the User.transaction_volume
feature. Please note that the --source: my_spanner
line is necessary
and should match the name
provided to your SpannerSource
. If you have a single integration,
you should use the name that is defined in the dashboard.