Fix problem with unprefixed group by columns in select queries #21370
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
When complex queries are built it can happen that some columns exists in more than one table.
The method to build the query had a bug, where the column names used in the order by were not prefixed in all cases.
I was able to reproduce the problem when setting
[General] enable_segments_cache = 0
in the config.And triggering the archiving for e.g. DevicesDetection while using a segment like
browserCode==FF
.The archiving for DevicesDetection will trigger an aggregation for conversion and so creates a query that joins log_visit and log_conversion. Both tables share a couple of dimensions. When it e.g. queries for config_browser_name, this fails if the column is not prefixed in order by.
Note: While moving around the code I was wondering about the special handling of
referrer_data
. Seems there actually is no reason for that special handling, as the way the query is built in transitions plugin could be easily changed to avoid any special handling at all.fixes #21351
Review