How to query Issue Link Types?

Eric Jacobson October 7, 2024

Is there a way to query the link type (e.g., "causes") of linked issues?

Screenshot 2024-10-07 144116.png

I am able to return linked issues using the method in this post:

https://confluence.atlassian.com/analyticskb/query-linked-jira-issues-1387597007.html

 

I just don't see a way to return only the linked issues that were linked as "causes" or "caused by". 

2 answers

1 accepted

0 votes
Answer accepted
Tracy Chow
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 16, 2024

Hi Eric,

Here is an example SQL code you can use for querying Atlassian Data Lake to capture the link type.

with tbl1 as (
  SELECT a.issue_id AS issue_id,
         a.issue_key AS issue_key,
       c.prev_value AS previous_value,
       DATE_FORMAT(c.started_at, 'yyyy-MM-dd HH:mm:ss') AS second_of_started_at,
       c.prev_value_string AS prev_value_string,
       c.value AS value,
       c.value_string AS value_string,
         CASE 
              WHEN c.prev_value_string is NULL then substr(c.value_string, 12, charindex(c.value, c.value_string)-13) 
              ELSE substr(c.prev_value_string, 12, charindex(c.prev_value, c.prev_value_string)-13) 
          END as link_type,
          CASE
              WHEN c.prev_value is NULL then c.value 
              ELSE c.prev_value 
          END as linked_issue,
          CASE 
              WHEN c.prev_value is NULL then "Added"
              ELSE "Removed" 
          END as change_type
FROM jira_issue AS a
INNER JOIN jira_project AS b ON a.project_id = b.project_id
INNER JOIN jira_issue_history AS c ON c.issue_id = a.issue_id
WHERE (c.field = 'Link')
GROUP BY a.issue_id,
           a.issue_key,
         c.prev_value,
         DATE_FORMAT(c.started_at, 'yyyy-MM-dd HH:mm:ss'),
         c.prev_value_string,
         c.value,
         c.value_string,
           link_type,
           linked_issue,
           change_type
ORDER BY a.issue_id ASC,
           a.issue_key ASC,
         c.prev_value ASC,
         DATE_FORMAT(c.started_at, 'yyyy-MM-dd HH:mm:ss') ASC,
         c.prev_value_string ASC,
         c.value ASC,
         c.value_string ASC,
           link_type ASC,
           linked_issue ASC,
           change_type ASC
),

tbl2 as (
  SELECT count(a.issue_key) over (partition by a.issue_key, a.link_type, a.linked_issue order by a.second_of_started_at DESC) as row_num,
  a.issue_id,
  a.issue_key,
  a.link_type,
  a.linked_issue,
  a.change_type
  FROM tbl1 as a
),

tbl3 as (
  SELECT a.issue_id,
  a.issue_key,
  a.link_type,
  a.linked_issue
  FROM tbl2 a
  WHERE a.row_num = 1
  AND a.change_type = "Added"
)

SELECT * from tbl3 

 Let me know if this works for you! 

Eric Jacobson October 23, 2024

It totally works, @Tracy Chow ! Thank you so much!

Like Tracy Chow likes this
0 votes
Bhanu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 7, 2024

Hi @Eric Jacobson 

Welcome to the Community!

You can use the issueLinkType function for this. For Example: issueLinkType in ("causes")

Refer to the following link from Atlassian which has a more detailed explanation.

https://confluence.atlassian.com/jirakb/how-to-retrieve-linkedissues-of-a-particular-issuelinktype-1318880958.html

Eric Jacobson October 8, 2024

That does not look like Atlassian Analytics. Are you saying I can use said function to query the Atlassian Analytics data lake, @Bhanu ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events