Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archiver join generator might not be able to join tables under circumstances #11697

Open
tsteur opened this issue May 14, 2017 · 0 comments
Open
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.

Comments

@tsteur
Copy link
Member

tsteur commented May 14, 2017

See https://github.com/piwik/piwik/pull/11690/files#r116174106

When generating an archiver query with such tables:

        $generator = $this->generate(array(
            'log_visit',
            'log_conversion',
            'log_link_visit_action',
            array('table' => 'log_conversion', 'joinOn' => 'log_link_visit_action.idvisit2 = log_conversion.idvisit2')
        ));

The query won't be able to join the table because it would need to restructure the whole array and detect which tables are joined in each join etc. Eg in this case we would expect output to be like this:

  $generator = $this->generate(array(
            'log_visit',
            'log_link_visit_action',
            array('table' => 'log_conversion', 'joinOn' => 'log_link_visit_action.idvisit2 = log_conversion.idvisit2')
        ));

In another case we would maybe move the log_conversion join further up if another table references it. eg

  $generator = $this->generate(array(
            'log_visit',
            'log_conversion',
            array('table' => 'log_action', 'joinOn' => 'log_action.idvisit2 = log_conversion.idvisit2')
            'log_link_visit_action',
            array('table' => 'log_conversion', 'joinOn' => 'log_link_visit_action.idvisit2 = log_conversion.idvisit2')
        ));

should result in

  $generator = $this->generate(array(
            'log_visit',
              'log_link_visit_action',
            array('table' => 'log_conversion', 'joinOn' => 'log_link_visit_action.idvisit2 = log_conversion.idvisit2')
            array('table' => 'log_action', 'joinOn' => 'log_action.idvisit2 = log_conversion.idvisit2')
        ));

This can get even more complicated the more tables there are joined etc and we need to consider which tables can be joined with which tables automatically. We cannot simply set a log_link_visit_action table after a log_visit table but need to make sure they can be joined automatically.

So far we throw an exception when this case happens so a developer can change the order manually in the archiver query. Ideally we would resolve this completely. Won't be trivial at all.

Please note that this should only happen when there are custom joins that are not on idvisit or when there are multiple joins. When using idvisit some of the complex logic is already implemented to resolve this.

@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels May 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.
Projects
None yet
Development

No branches or pull requests

2 participants