Good morning community!
I am trying to join two tables together, but my 'key' contains multiple items within a given cell. Is there a way to index through each item within the cell to check for a match / join?
In the top table key SR-3679 is "tested by" three different "TER" links. The bottom table provides the details for the individual "TER" issues. I need to be able to either:
Any suggestions, please!
Hi @Emily Berg ,
We've recreated your case here:
If you have the only one type of keys (TER-XX), then we suggest using the following SQL query (it will be a more reliable one):
SELECT * FROM T1
LEFT JOIN T2 ON T1.'Tested by'->split("TER-")->indexOf(REPLACE(T2.'TER Key', "TER-", "")) > -1
If you have other types of projects (keys), then you may use a simpler query:
SELECT * FROM T1
LEFT JOIN T2 ON T1.'Tested by'->indexOf(T2.'TER Key') > -1
Hope this helps your case.
@Katerina Kovriga {Stiltsoft} ,
This is AWESOME! Thank you very much for the response! Could you elaborate on why the first solution would be more reliable (for my own edification)?
Emily
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The first variant splits and then joins your keys strictly - as you can see, there is the name of your project "TER-" included into the 'split' and 'indexOf' sql functions.
If you work with another project, then you'll have other keys (for example, WER-13, WER-15, etc.) and put "WER-" for 'split' and 'indexOf' functions.
The second variant is a more general and simple one. It works, but the result table should be checked manually at first if you have multiple project names with similar key indexes to prevent any mismatching.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Katerina Kovriga {Stiltsoft} ,
As you pointed out, the general approach is less robust and I am now seeing an issue because of similarities with other keys.
I have another problem regarding this request - my key field is not just "TER-", rather its a custom field that contains other text, e.g. "TER-XXX | Status | Summary". How would I break out just the key from this field in order to proceed with the split function mentioned above?
Emily
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Emily Berg ,
Not to mess up the original query, I suggest wrapping your second table with the combined TER Key into a separate Table Transformer:
Use the following SQL query to split your strings by the " | " symbols:
SELECT T1.'TER Key'->split(" | ")->0 AS 'TER Key',
T1.'TER Key'->split(" | ")->1 AS 'Description',
T1.'TER Key'->split(" | ")->2 AS 'Description2',
T1.'TER Summary'
FROM T*
And here is the result table for the first Table Transformer with the original SQL query:
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Katerina Kovriga {Stiltsoft} ,
Now that I have expanded my use of this query, I am running into another issue. I am getting partial matches when using the index query.
I have two tables:
One containing "Key", "Summary", "Tested By", and "Tested-By-Key"
One containing "TER Key" and "TER Summary".
I am using the following query to merge the two tables based on the T1.'Tested-By-Key' to T2.'TER Key':
SELECT * FROM T1
LEFT JOIN T2 ON T1.'tested-by-key'->indexOf(T2.'TER Key') > -1
For this example, there should only be one match - IVDTER-168, but a partial match of IVDTER-16 is also appearing in the joining operation. Is there a different query that enables an exact match only?
Thank you,
Emily
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Emily Berg ,
I think we should stick to the more specific SQL query that I mentioned first - the one that includes the name of the project.
If I remember your case right, you are trying to merge the two tables that look similar to this screenshot:
The second table was divided by the internal Table Transformer macro:
Now try to merge these two tables with the help of the following SQL query:
SELECT * FROM T1
LEFT JOIN T2 ON
T1.'Tested-by-key'->split("TER-")->indexOf(REPLACE(T2.'TER Key', "TER-", ""))>-1
As you can see, the TER-16 and TER-11 cells (with the orange background) weren't matched to the TER-168 and TER-118 by partial match.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Katerina Kovriga {Stiltsoft} ,
Thank you for the fast reply. This does work - but what about cases where the prefix ("TER-") is not always the same? I could do a case within the query to extract just the number, but then I could get duplicates depending on the prefix...e.g. TER-147 and IVDTER-147. Thoughts with this use case?
Thanks,
Emily
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll consult with our developers tomorrow and get back to you - can't come up with a better idea for the case with different prefixes.
As a straightforward workaround, you may use several Transformers - each one for every prefix (I assume that one or both of your tables come from the Jira Issues macro, so you may filter and process every project separately). The result table could be combined using an additional Transformer with a standard Merge preset.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Emily Berg ,
Here I am with a rather complex SQL query from our developers:
SELECT * FROM T1
LEFT JOIN T2 ON
T1.'Tested-by-key'->match("(^|[0-9])" + T2.'TER Key' + "([^0-9]|$)")
As far as I can see, the query matches your case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are these tables a result of JIRA filters?
Anyway, if I understood your question right, then this might help:
You already have the table for SR issues (let this be T1)
Filter and create a separate table for all TER issues affected in your SR table(let this be T2), then with these 2 tables in the same table transformer macro:
SELECT
(SELECT T1.'Key' FROM T1 WHERE T2.'TER Key' IN T1.'Tested By') AS 'SR Key',
T2.'TER Key',
T2.'TER Summary',
...
any other columns
...
FROM T2
This way you will have something like this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kántor Tibor - Thanks for the response. This works only for the first row of T1 data. I need to be able to loop this function through a large T1 with multiple rows. Is there a way to incorporate a while loop or something similar to index through the entire T1 table?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure why... I have the same setup, separating linked issues to different rows, and it loops through the whole T1 table. Might not be a while loop issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.