Package: dbt-decodable
dbt-decodabledbtadapter forDecodable.dbtenables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.Decodable is a fully managed stream processing service, based on [Apache Flink®] and using SQL as the primary means of defining data streaming pipelines.Installationdbt-decodableis available onPyPI. To install the latest version viapip(optionally using a virtual environment),
run:python3 -m venv dbt-venv         # create the virtual environment
source dbt-venv/bin/activate     # activate the virtual environment
pip install dbt-decodable        # install the adapterGetting StartedOnce you've installed dbt in a virtual environment, we recommend trying out the example project provided by decodable:# clone the example projectgitclonehttps://github.com/decodableco/dbt-decodable.gitcddbt-decodable/example_project/example/# Ensure you can connect to decodable via the decodable CLI:# If you don't have installed the decodable CLI,# install it following these instructions: https://docs.decodable.co/docs/setup#install-the-cli-command-line-interfacedecodableconnectionlist# Ensure you have a  ~/.dbt/profiles.yml file:cat~/.dbt/profiles.yml
dbt-decodable:# this name must match the 'profile' from dbt_project.ymloutputs:dev:account_name:<fillinyourdecodableaccountname>profile_name:default# fill in any profile defined in ~/.decodable/configtype:decodabledatabase:dbschema:demolocal_namespace:dbt_demotarget:dev# This will launch the example projectdbtrunNote that this dbt adapter ignores theactive-profilesetting in~/.decodable/config. You must put the decodable profile you want to use
in the~/.dbt/profiles.ymlfile into theprofile_namesetting.
The adapter does not support a custom decodablebase-url(e.g. for local development or proxies).Configuring your profileProfiles in dbt describe a set of configurations specific to a connection with the underlying data warehouse. Each dbt project should have a corresponding profile (though profiles can be reused for different project). Within a profile, multiple targets can be described to further control dbt's behavior. For example, it's very common to have adevtarget for development and aprodtarget for production related configurations.Most of the profile configuration options available can be found inside thedbt documentation. Additionally,dbt-decodabledefines a few adapter-specific ones that can be found below.dbt-decodable:        # the name of the profile
  target: dev         # the default target to run commands with
  outputs:            # the list of all defined targets under this profile
    dev:              # the name of the target
      type: decodable
      database: None  # Ignored by this adapter, but required properties
      schema: None    # Ignored by this adapter, but required properties

      # decodable specific settings
      account_name: [your account]          # Decodable account name
      profile_name: [name of the profile]   # Decodable profile name
      materialize_tests: [true | false]     # whether to materialize tests as a pipeline/stream pair, default is `false`
      timeout: [ms]                         # maximum accumulative time a preview request should run for, default is `60000`
      preview_start: [earliest | latest]    # whether preview should be run with `earliest` or `latest` start position, default is `earliest`
      local_namespace: [namespace prefix]   # prefix added to all entities created on Decodable, default is `None`, meaning no prefix gets added.dbt looks for theprofiles.ymlfile in the~/.dbtdirectory. This file contains all user profiles.Supported FeaturesMaterializationsOnly tablematerializationis supported for dbt models at the moment. A dbt table model translates to a pipeline/stream pair on Decodable, both sharing the same name. Pipelines for models are automatically activated upon materialization.To materialize your models simply run thedbt runcommand, which will perform the following steps for each model:Create a stream with the model's name and schema inferred by Decodable from the model's SQL.Create a pipeline that inserts the SQL's results into the newly created stream.Activate the pipeline.By default, the adapter will not tear down and recreate the model on Decodable if no changes to the model have been detected. However, if changes
to a decodable stream have been detected, it will be deleted and recreated. We recommend configuring alocal_namespacefor dbt-managed
resources to prevent accidential deletion of streams.
Invoking dbt with the--full-refreshflag set, or setting that configuration option for a specific model will cause the corresponding resources on Decodable to be destroyed and built from scratch. See thedocsfor more information on using this option.Custom model configurationAwatermarkoption can be configured to specify thewatermarkto be set for the model's respective Decodable stream. See thehttp events example.Aprimary_keyoption can be configured to specify the primary key if the target stream is achange stream. See thegroup by example.More on specifying configuration options per model can be foundhere.Seedsdbt seedwill perform the following steps for each specified seed:Create a REST connection and an associated stream with the same name (reflecting the seed's name).Activate the connection.Send the data stored in the seed's.csvfile to the connection as events.Deactivate the connection.After these steps are completed, you can access the seed's data on the newly created stream.SourcesSourcesin dbt correspond to Decodable's source connections. However,dbt sourcecommand is not supported at the moment.Documentationdbt docsis not supported at the moment. You can check your Decodable account for details about your models.TestingBased on thematerialize_testsoption set for the current target,dbt testwill behave differently:materialize_tests = falsewill cause dbt to run the specified tests as previews return the results after they finish. The exact time the preview runs for, as well as whether they run starting positions should be set toearliestorlatestcan be changed using thetimeoutandpreview_starttarget configurations respectively.materialize_tests = truewill cause dbt to persist the specified tests as pipeline/stream pairs on Decodable. This configuration is designed to allow continous testing of your models. You can then run a preview on the created stream (for example usingDecodable CLI) to monitor the results.SnapshotsNeither the [dbt snapshot] command nor the notion of snapshots are supported at the moment.Additional Operationsdbt-decodableprovides a set of commands for managing the project's resources on Decodable. Those commands can be run usingdbt run-operation {name} --args {args}.Example invocation of thedelete_streamsoperation detailed below:$dbtrun-operationdelete_streams--args'{streams: [stream1, stream2], skip_errors: True}'stop_pipelines(pipelines)pipelines: Optional list of names. Default value isNone.Deactivate pipelines for resources defined within the project. If thepipelinesarg is provided, the command only considers the listed resources. Otherwise, it deactivates all pipelines associated with the project.delete_pipelines(pipelines)pipelines: Optional list of names. Default value isNone.Delete pipelines for resources defined within the project. If thepipelinesarg is provided, the command only considers the listed resources. Otherwise, it deletes all pipelines associated with the project.delete_streams(streams, skip_errors)streams: Optional list of names. Default value isNone.skip_errors: Whether to treat errors as warnings. Default value istrue.Delete streams for resources defined within the project. Note that it does not delete pipelines associated with those streams, failing to remove a stream if one exists. For a complete removal of stream/pipeline pairs, see thecleanupoperation.If thestreamsarg is provided, the command only considers the listed resources. Otherwise, it attempts to delete all streams associated with the project.Ifskip_errorsis set totrue, failure to delete a stream (e.g. due to an associated pipeline) will be reported as a warning. Otherwise, the operation stops upon the first error encountered.cleanup(list, models, seeds, tests)list: Optional list of names. Default value isNone.models: Whether to include models during cleanup. Default value istrue.seeds: Whether to include seeds during cleanup. Default value istrue.tests: Whether to include tests during cleanup. Default value istrue.Delete all Decodable entities resulting from the materialization of the project's resources, i.e. connections, streams and pipelines.If thelistarg is provided, the command only considers the listed resources. Otherwise, it deletes all entities associated with the project.Themodels,seedsandtestsarguments specify whether those resource types should be included in the cleanup. Note that cleanup does nothing for tests that have not been materialized.Known limitationsThe dbt decodable adapter does not allow managing decodable connectors via dbt. You can only create streams and pipelines with dbt.ContributionsContributions to this repository are more than welcome.
Please create any pull requests against the [main] branch.Each release is maintained in areleases/*branch, such asreleases/v1.3.2, and there's a tag for it.Build local versionpipinstall.How to create a releaseThis is based on an example release calledv1.3.3.# We assume to be on 'main'.# Fork into release branchgitcheckout-breleases/v1.3.3# Edit pyproject.toml and set: version = "1.3.3"vipyproject.toml# create release commitgitcommit-am"[#2] Set version to v1.3.3"# Create a release with a tag from the GitHub UI pointing to the commit we just created.# CI will do the rest.LicenseThis code base is available under the Apache License, version 2.Apache Flink, Flink®, Apache®, the squirrel logo, and the Apache feather logo are either registered trademarks or trademarks of The Apache Software Foundation.