fivetran / dbt_jira

Data models for Fivetran's Jira connector built using dbt.
https://fivetran.github.io/dbt_jira/
Apache License 2.0
8 stars 15 forks source link

Join to Component when there are multiple components on jira__daily_issue_field_history #123

Open abrown-calix opened 6 months ago

abrown-calix commented 6 months ago

Is there an existing issue for this?

Describe the issue

In our organization we can have multiple components for one jira story. We added component to our list of columns we want to see in the dbt_project.yml issue_field_history_columns variable and it seems to work up to a point. In reviewing the jira__daily_issue_field_history there is a join in the set_values CTE where it does not account for the fact we can have multiple values. If we could add the join further up stream to get the correct values that would be greatly beneficial.

Relevant error log or model output

As a work around we have had to 
- flatten the components column from the jira__issue_enhanced dbt model
- then join to stg_jira__component to get the actual name of the component
- then listagg the name partitioning by the issue_id

`with test as (
SELECT trim(f.value) as component_id, a.* --f.value as component_id_new, a.*
FROM ANALYTICS.JIRA.JIRA_ISSUE a,
LATERAL SPLIT_TO_TABLE(a.components, ',') f
WHERE ISSUE_ID IN (948017,
                   925164)
)

select a.issue_id
   ,a.components
    ,a.component_id
    ,b.component_name
    ,coalesce(b.component_name, a.component_id) as new_component_name
from test a
left join analytics.stg.stg_jira__component b on a.component_id = b.component_id::varchar
;  `

![image](https://github.com/fivetran/dbt_jira/assets/127148173/7482fee9-7a99-4807-a8a9-40589ebbc94d)

Thanks!

Expected behavior

That the components all are the names of the components and not just those where a story has one component listed

dbt Project configurations

issue_field_history_columns: ['Story Points','Summary','Components']

Package versions

version: 0.15.0

What database are you using dbt with?

snowflake

dbt Version

1.7.9

Additional Context

No response

Are you willing to open a PR to help address this issue?

fivetran-reneeli commented 6 months ago

Hi @abrown-calix ,thanks for opening this. I'm understanding that you wish to be able to bring multiple values that can be tied to a Jira entity through in the model. This is a limitation that we're aware of and we have a Feature Request opened here that you may follow.

Thanks for sharing your workaround! I see you're open to creating a PR, we welcome that! Let me know if you have other notes you'd like to share.

-- 4/1/24 update-- corrected the link pointing to the relevant FR