Transform Data with dbt

The dbt-singlestore adapter can be used to connect with your SingleStore database to build data transformation pipelines using dbt. dbt provides a development environment to create transformation workflows on data that is already in SingleStore, which dbt turns into tables and views through SELECT statements. See dbt documentation for more information.

Prerequisites

The dbt-singlestore adapter is compatible with the the following versions:

SingleStore

dbt

7.6.x

1.0.1

Download and Install the SingleStore dbt Adapter

You can download the dbt-singlestore adapter from the Python Package Index repository (PyPI). Run the following command to install the adapter available on PyPI:

pip install dbt-singlestore

You can also install the package from GitHub:

pip install git+https://github.com/memsql/dbt-singlestore.git

Configure the SingleStore Profile

dbt uses the profiles.yml file as a standard profile for SQL data sources. Here's a sample configuration:

default:
outputs:
dev:
type: singlestore
host: <database_host>
port: <database_port>
user: <database_user>
password: <database_user_password>
database: <database_name> # required
schema: <name_for_dbt_internal_processing> # required
threads: <number of threads> # default: 1
target: dev

Note

Always specify the type as singlestore. You must include the type either in profiles.yml or dbt_project.yml.

Configuration

Description

Required

host

The IP address or the hostname of the SingleStore cluster.

No

user

The SingleStore database username.

No

password

Password of the SingleStore user.

No

database

The name of the SingleStore database. If you are using custom database names in your model configuration, you must create them before running the models.

Yes

schema

See Schema and Concurrent Development.

Yes

threads

The number of threads available to dbt.

No

Schema and Concurrent Development

In SingleStore, database and schema denote the same concepts. In dbt, a schema refers to a namespace within a database. Therefore, you must specify the schema in profile.yml for dbt to work with the project metadata.

To support concurrent development, prefix the table names that dbt is building within the database with schema. The following macro prefixes the table names with schema:

{% macro generate_alias_name(custom_alias_name=none, node=none) -%}
    {%- if custom_alias_name is none -%}
        {{ node.schema }}__{{ node.name }}
    {%- else -%}
        {{ node.schema }}__{{ custom_alias_name | trim }}
    {%- endif -%}
{%- endmacro %}

For example, if you have a model named customers and schema is set to dev, without this macro, dbt creates a table named customers in the database. When this macro is added to the project, dbt creates a table named dev__customers.

See SingleStore Profile for more information.

Last modified: September 27, 2023

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK