This library provides a Dagster integration with dbt (data build tool), created by Fishtown Analytics.
dagster_dbt.
dbt_cli_run
(context)[source]¶This solid executes dbt run
via the dbt CLI. See the solid definition for available
parameters.
dagster_dbt.
dbt_cli_run_operation
(context)[source]¶This solid executes dbt run-operation
via the dbt CLI.
dagster_dbt.
dbt_cli_snapshot_freshness
(context)[source]¶This solid executes dbt source snapshot-freshness
via the dbt CLI.
dagster_dbt.
dbt_cli_test
(context)[source]¶This solid executes dbt test
via the dbt CLI. See the solid definition for available
parameters.
dagster_dbt.
DbtCliOutput
(result, command, return_code, raw_output, num_pass=None, num_warn=None, num_error=None, num_skip=None, num_total=None)[source]¶The results of executing a dbt command, along with additional metadata about the dbt CLI process that was run.
Note that users should not construct instances of this class directly. This class is intended to be constructed from the JSON output of dbt commands.
If the executed dbt command is either run
or test
, then the .num_*
attributes will
contain non-None
integer values. Otherwise, they will be None
.
from_dict
(d)[source]¶Constructs an instance of DbtCliOutput
from a
dictionary.
d (Dict[str, Any]) – A dictionary with key-values to construct a DbtCliOutput
.
An instance of DbtCliOutput
.
dagster_dbt.
create_dbt_rpc_run_sql_solid
(name, output_def=None, **kwargs)[source]¶This function is a factory which constructs a solid that will copy the results of a SQL query
run within the context of a dbt project to a pandas DataFrame
.
Any kwargs passed to this function will be passed along to the underlying @solid
decorator. However, note that overriding config_schema
, input_defs
, and
required_resource_keys
is not allowed and will throw a DagsterInvalidDefinitionError
.
If you would like to configure this solid with different config fields, you could consider using
@composite_solid
to wrap this solid.
name (str) – The name of this solid.
output_def (OutputDefinition, optional) – The OutputDefinition
for the solid. This value should always be a representation
of a pandas DataFrame
. If not specified, the solid will default to an
OutputDefinition
named “df” with a DataFrame
dagster type.
Returns the constructed solid definition.
dagster_dbt.
dbt_rpc_compile_sql
(context, sql)[source]¶This solid sends the dbt compile
command to a dbt RPC server and returns the request
token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_run
(context)[source]¶This solid sends the dbt run
command to a dbt RPC server and returns the request token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_run_and_wait
(context)[source]¶This solid sends the dbt run
command to a dbt RPC server and returns the result of the
executed dbt process.
This dbt RPC solid is synchronous, and will periodically poll the dbt RPC server until the dbt process is completed.
dagster_dbt.
dbt_rpc_run_operation
(context)[source]¶This solid sends the dbt run-operation
command to a dbt RPC server and returns the
request token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_run_operation_and_wait
(context)[source]¶This solid sends the dbt run-operation
command to a dbt RPC server and returns the
result of the executed dbt process.
This dbt RPC solid is synchronous, and will periodically poll the dbt RPC server until the dbt process is completed.
dagster_dbt.
dbt_rpc_snapshot
(context)[source]¶This solid sends the dbt snapshot
command to a dbt RPC server and returns the
request token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_snapshot_and_wait
(context)[source]¶This solid sends the dbt snapshot
command to a dbt RPC server and returns the result of
the executed dbt process.
This dbt RPC solid is synchronous, and will periodically poll the dbt RPC server until the dbt process is completed.
dagster_dbt.
dbt_rpc_snapshot_freshness
(context)[source]¶This solid sends the dbt source snapshot-freshness
command to a dbt RPC server and
returns the request token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_snapshot_freshness_and_wait
(context)[source]¶This solid sends the dbt source snapshot
command to a dbt RPC server and returns the
result of the executed dbt process.
This dbt RPC solid is synchronous, and will periodically poll the dbt RPC server until the dbt process is completed.
dagster_dbt.
dbt_rpc_test
(context)[source]¶This solid sends the dbt test
command to a dbt RPC server and returns the request token.
This dbt RPC solid is asynchronous. The request token can be used in subsequent RPC requests to poll the progress of the running dbt process.
dagster_dbt.
dbt_rpc_test_and_wait
(context)[source]¶This solid sends the dbt test
command to a dbt RPC server and returns the result of the
executed dbt process.
This dbt RPC solid is synchronous, and will periodically poll the dbt RPC server until the dbt process is completed.
dagster_dbt.
dbt_rpc_resource
ResourceDefinition[source]¶This resource defines a dbt RPC client.
To configure this resource, we recommend using the configured method.
Examples:
custom_dbt_rpc_resource = dbt_rpc_resource.configured({"host": "80.80.80.80","port": 8080,})
@pipeline(mode_defs=[ModeDefinition(resource_defs={"dbt_rpc": custom_dbt_rpc_resource})])
def dbt_rpc_pipeline():
# Run solids with `required_resource_keys={"dbt_rpc", ...}`.
dagster_dbt.
local_dbt_rpc_resource
ResourceDefinition¶This resource defines a dbt RPC client for an RPC server running on 0.0.0.0:8580.
dagster_dbt.
DbtRpcClient
(host='0.0.0.0', port=8580, jsonrpc_version='2.0', logger=None, **_)[source]¶A client for a dbt RPC server.
If you are need a dbt RPC server as a Dagster resource, we recommend that you use
dbt_rpc_resource
.
cli
(*, cli, **kwargs)[source]¶Sends a request with CLI syntax to the dbt RPC server, and returns the response. For more details, see the dbt docs for running CLI commands via RPC.
cli (str) – a dbt command in CLI syntax.
the HTTP response from the dbt RPC server.
Response
compile
(*, models=None, exclude=None, **kwargs)[source]¶Sends a request with the method compile
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for compiling projects via RPC.
compile_sql
(*, sql, name)[source]¶Sends a request with the method compile_sql
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for compiling SQL via RPC.
generate_docs
(*, models=None, exclude=None, compile=False, **kwargs)[source]¶Sends a request with the method docs.generate
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for the RPC method docs.generate.
the HTTP response from the dbt RPC server.
Response
kill
(*, task_id)[source]¶Sends a request with the method kill
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method kill.
task_id (str) – the ID of the task to terminate.
the HTTP response from the dbt RPC server.
Response
logger
¶A property for injecting a logger dependency.
Optional[Any]
poll
(*, request_token, logs=False, logs_start=0)[source]¶Sends a request with the method poll
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method poll.
ps
(*, completed=False)[source]¶Sends a request with the method ps
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method ps.
compelted (bool) – If True
, then also return completed tasks. Defaults to False
.
the HTTP response from the dbt RPC server.
Response
run
(*, models=None, exclude=None, **kwargs)[source]¶Sends a request with the method run
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method run.
run_operation
(*, macro, args=None, **kwargs)[source]¶Sends a request with the method run-operation
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for the command run-operation.
run_sql
(*, sql, name)[source]¶Sends a request with the method run_sql
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for running SQL via RPC.
seed
(*, show=False, **kwargs)[source]¶Sends a request with the method seed
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method seed.
show (bool, optional) – If True
, then show a sample of the seeded data in the
response. Defaults to False
.
the HTTP response from the dbt RPC server.
Response
snapshot
(*, select=None, exclude=None, **kwargs)[source]¶Sends a request with the method snapshot
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for the command snapshot.
snapshot_freshness
(*, select=None, **kwargs)[source]¶Sends a request with the method snapshot-freshness
to the dbt RPC server, and returns
the response. For more details, see the dbt docs for the command source snapshot-freshness.
select (List[str], optional) – the models to include in calculating snapshot freshness.
the HTTP response from the dbt RPC server.
Response
status
()[source]¶Sends a request with the method status
to the dbt RPC server, and returns the
response. For more details, see the dbt docs for the RPC method status.
the HTTP response from the dbt RPC server.
Response
test
(*, models=None, exclude=None, data=True, schema=True, **kwargs)[source]¶Sends a request with the method test
to the dbt RPC server, and returns the response.
For more details, see the dbt docs for the RPC method test.
the HTTP response from the dbt RPC server.
Response
dagster_dbt.
DbtRpcOutput
(result, state, start, end, elapsed)[source]¶The output from executing a dbt command via the dbt RPC server.
Note that users should not construct instances of this class directly. This class is intended to be constructed from the JSON output of dbt commands.
from_dict
(d)[source]¶Constructs an instance of DbtRpcOutput
from a
dictionary.
d (Dict[str, Any]) – A dictionary with key-values to construct a DbtRpcOutput
.
An instance of DbtRpcOutput
.
dagster_dbt.
DbtResult
(logs, results, generated_at=None, elapsed_time=None)[source]¶The results of executing a dbt command.
Note that users should not construct instances of this class directly. This class is intended to be constructed from the JSON output of dbt commands.
results
¶Details about each executed dbt node (model) in the run.
List[NodeResult]]
dagster_dbt.
NodeResult
(node=None, unique_id=None, error=None, status=None, execution_time=None, thread_id=None, step_timings=None, table=None, fail=None, warn=None, skip=None)[source]¶The result of executing a dbt node (model).
Note that users should not construct instances of this class directly. This class is intended to be constructed from the JSON output of dbt commands.
fail
¶The fail
field from the results of the executed dbt node.
Optional[Any]
warn
¶The warn
field from the results of the executed dbt node.
Optional[Any]
skip
¶The skip
field from the results of the executed dbt node.
Optional[Any]
step_timings
¶The timings for each step in the executed dbt node (model).
List[StepTiming]
table
¶Details about the table/view that is created from executing a run_sql command on an dbt RPC server.
Optional[Dict]
from_dict
(d)[source]¶Constructs an instance of NodeResult
from a dictionary.
d (Dict[str, Any]) – A dictionary with key-values to construct a NodeResult
.
An instance of NodeResult
.
dagster_dbt.
StepTiming
(name, started_at, completed_at)[source]¶The timing information of an executed step for a dbt node (model).
Note that users should not construct instances of this class directly. This class is intended to be constructed from the JSON output of dbt commands.
started_at
¶An ISO string timestamp of when the step started executing.
completed_at
¶An ISO string timestamp of when the step completed execution.
duration
¶The execution duration of the step.
dagster_dbt.
DagsterDbtError
(description=None, metadata_entries=None, metadata=None)[source]¶The base exception of the dagster-dbt
library.
dagster_dbt.
DagsterDbtCliRuntimeError
(description, logs, raw_output)[source]¶Represents an error while executing a dbt CLI command.
dagster_dbt.
DagsterDbtCliFatalRuntimeError
(logs, raw_output)[source]¶Represents a fatal error in the dbt CLI (return code 2).
dagster_dbt.
DagsterDbtCliHandledRuntimeError
(logs, raw_output)[source]¶Represents a model error reported by the dbt CLI at runtime (return code 1).
dagster_dbt.
DagsterDbtCliOutputsNotFoundError
(path)[source]¶Represents a problem in finding the target/run_results.json
artifact when executing a dbt
CLI command.
For more details on target/run_results.json
, see
https://docs.getdbt.com/reference/dbt-artifacts#run_resultsjson.