Hi how can I select the models from a dbt rpc? th...
# ask-community
s
Hi how can I select the models from a dbt rpc? the "select" parameter is not working ...
Copy code
custom_dbt_rpc_resource = dbt_rpc_resource.configured({
	"host": dbt_client['host'],
	"port": dbt_client['port'],
	#"select": ["employee"]
})

@job(
    resource_defs={
		"dbt": custom_dbt_rpc_resource
	}
)
def main():
	dbt_run_op()
🤖 1
s
cc @owen
o
hi @Saul Burgos! this is definitely a bit annoying from our side, as the dbt_rpc_resource doesn't respect the "default parameters" in the same way that the dbt_cli_resource does. I think the easiest thing to do here would be to write your own dbt op that passes in the select parameter directly. I think this should work:
Copy code
custom_dbt_rpc_resource = dbt_rpc_resource.configured({
	"host": dbt_client['host'],
	"port": dbt_client['port'],
	#"select": ["employee"]
})

@op(required_resource_keys={"dbt"})
def dbt_run_employees_op(context):
    return context.resources.dbt.run(select=["employee"])

@job(
    resource_defs={
		"dbt": custom_dbt_rpc_resource
	}
)
def main():
	dbt_run_employees_op()
if you want your custom op to also emit the AssetMaterialization events, you can copy what we do for the actual
dbt_run_op
from here: https://sourcegraph.com/github.com/dagster-io/dagster/-/blob/python_modules/libraries/dagster-dbt/dagster_dbt/ops.py?L95:5
if you want that select parameter to be configurable, you can do that via op config on your custom op
s
@owen I will do it , thanks
@owen working perfectly... Just another question. Maybe is a crazy question but... Do you think that is possible to change of schema and DB .... using this technique?? Maybe the question didn't make sense....
I am not expert on dbt ... just asking
o
not sure your exact situation, but it's possible that you could set up multiple different targets: https://docs.getdbt.com/dbt-cli/configure-your-profile#understanding-targets-in-profiles, then choose which target you want to use via
context.resources.dbt.run(target="my_target")
s
Thanks