Chalk supports Spanner as a natively accelerated SQL source.


Adding Spanner

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 by navigating to Integrations > Add a data source and selecting Spanner.


Integrations Setup

After configuring your Spanner integration in the dashboard, define your data sources in Python:

from chalk.sql import SpannerSource

spanner_source_txns = SpannerSource(name="SPANNER_TRANSACTIONS")
spanner_source_marketing = SpannerSource(name="SPANNER_MARKETING")

Then reference them in SQL file resolvers using the name parameter. For example, to query from the SPANNER_TRANSACTIONS source:

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

And to query from the SPANNER_MARKETING source:

-- type: online
-- resolves: User
-- source: SPANNER_MARKETING
SELECT
    id,
    email,
    campaign_status
FROM
    MarketingTable