Parse joined relations with `USING` keyword
Background
This is follow up to #323219 (closed)
In usage_data.rb
there is one metric defined, that joins relation to its instrumentation query, with usage of USING
keyword.
Goal
Enhance name suggestion implementation to handle USING
keyword the same way as it is done with ON
keyword.
From #323219 (closed)
To base format
operation_target_having_<adjectives describing>_source
oroperation_<adjectives describing>_target
joined relations should be included be using following rules:
- Joined relations included into metric name, should persist structure of joined relations, meaning when to source A joined was relation B, and than to B was joined relation C (eg:
Select a.id FROM a JOIN b USING (a_id)
) than name should reflect that- When counted is foreign key of other relation eg
b.d_id
we should translate it as itd
relation was joined into the query- Conjunction should be used in consistent manner in order to help express joined relation structure, so use different conjunction for different levels relations eg:
Select count(a.id) FROM a JOIN b USING(a_id) JOIN c ON c.b_id = b.id JOIN d ON d.a_id = a.id
should usewith
conjunction forb
andd
relations andincluding
forc
. count_a_with_b_including_c_with_d
Implementation
Most likely changes should be done within: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage/metrics/names_suggestions/relation_parsers/joins.rb#L18
Edited by Mikołaj Wawrzyniak