Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

analyzer: fix pushdown of filters with repeated table names #498

Merged
merged 1 commit into from
Oct 24, 2018

Conversation

erizocosmico
Copy link
Contributor

@erizocosmico erizocosmico requested a review from a team October 24, 2018 10:32
@@ -18,11 +18,15 @@ func (f filters) merge(f2 filters) {
func exprToTableFilters(expr sql.Expression) filters {
filtersByTable := make(filters)
for _, expr := range splitExpression(expr) {
var seenTables = make(map[string]struct{})
var tables []string
Copy link
Contributor

@kuba-- kuba-- Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need var tables []string now? If we just check:

if len(tables) == 1 {
   filtersByTable[tables[0]] = append(filtersByTable[tables[0]], expr)		 			       filtersByTable[tables[0]] = append(filtersByTable[tables[0]], expr)
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you get the key from the map, then? You would need to range the map and that feels like this with extra steps

Copy link
Contributor

@kuba-- kuba-- Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true - we'll need to range and break, but on the other hand if we really need just 0th element then we may just memorise just one string instead of all slice and only set it if len(seen) == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
@erizocosmico
Copy link
Contributor Author

erizocosmico commented Oct 24, 2018

Can we merge this before I update gitbase, so it also gets this fix? @ajnavarro

@ajnavarro ajnavarro merged commit a9eddbf into src-d:master Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants