generate sql comand that fetch all the job_name th...
# ask-elementary-ai
j
generate sql comand that fetch all the job_name that runs dbt job has a tag:daily from the elementary table dbt_invocations
k
A message from kapa.ai
Based on the knowledge sources, I can provide you with a SQL query to fetch all job names that run dbt jobs with the tag "daily" from the Elementary table
dbt_invocations
. The
dbt_invocations
table in Elementary captures metadata about your dbt jobs, including information about the selected tags. Here's a SQL query that should help you find job names for jobs that include the "daily" tag:
Copy code
sql SELECT DISTINCT job_name FROM your_elementary_schema.dbt_invocations WHERE selected LIKE '%"run_daily"%'    AND job_name IS NOT NULL ORDER BY job_name;
Note that: 1. You'll need to replace
your_elementary_schema
with your actual Elementary schema name 2. The
selected
column in
dbt_invocations
stores the tags as a JSON array string, so we're using the LIKE operator to find entries containing "run_daily" 3. We're filtering out NULL job names If you're not seeing job names populated in your
dbt_invocations
table, you may need to set the job name explicitly. According to the documentation, you can do this by: 1. Setting an environment variable called
JOB_NAME
or
DBT_JOB_NAME
in your orchestrator 2. Or passing it as a dbt var using
--vars '{"job_name": "your_job_name"}'
[Collect Jobs Info From Orchestrator](https://docs.elementary-data.com/oss/guides/collect-job-data) provides more details on how to ensure job metadata is properly captured. I hope this helps!