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

Requests having expressions with or queries are handled incorrectly #138

Closed
vania-pooh opened this issue Aug 6, 2016 · 5 comments
Closed
Milestone

Comments

@vania-pooh
Copy link
Member

vania-pooh commented Aug 6, 2016

See IndexFetch and TableScan case examples.

@vania-pooh vania-pooh added this to the 1.3.1 milestone Aug 6, 2016
@vania-pooh vania-pooh modified the milestones: 1.3.1, 1.3.2 Aug 24, 2016
@vania-pooh vania-pooh removed this from the 1.3.2 milestone Sep 23, 2016
@vania-pooh
Copy link
Member Author

vania-pooh commented Oct 18, 2016

An example where related issue is reproducing:

perspective>explain select name from instances where name regexp 'firefox43.*' or name regexp 'chrome44.*';
Results contain 3 entries.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ task                                                                                                                                                                             │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DataSourceTask{dataSource=DataSource{tableAlias='null', leftDataSource=DataSource{tableAlias='instances', leftDataSource=null, isNaturalJoin=false, joinType=null,               │
│ condition=null, columns=[name], rightDatasource=null, type=INDEX_FETCH}, isNaturalJoin=false, joinType=null, condition=null, columns=[], rightDatasource=null, type=PARENT},     │
│ tableAliases={instances=instances}}                                                                                                                                              │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ FilterTask{condition=name REGEXP firefox43.* && name REGEXP chrome44.*}                                                                                                          │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ SelectTask{selectionMap={name=name}, selectAll=false, tableAliases={instances=instances}}                                                                                        │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

We request OR but get AND in FilterTask.

@vania-pooh
Copy link
Member Author

However it works with IndexFetch:

perspective>explain select name from instances where name = 'firefox43-sg-e-1' or name = 'chrome44-sg-e-1';
Results contain 3 entries.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ task                                                                                                                                                                             │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DataSourceTask{dataSource=DataSource{tableAlias='null', leftDataSource=DataSource{tableAlias='instances', leftDataSource=null, isNaturalJoin=false, joinType=null,               │
│ condition=null, columns=[name], rightDatasource=null, type=INDEX_FETCH}, isNaturalJoin=false, joinType=null, condition=null, columns=[], rightDatasource=null, type=PARENT},     │
│ tableAliases={instances=instances}}                                                                                                                                              │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ FilterTask{condition=name = chrome44-sg-e-1 || name = firefox43-sg-e-1}                                                                                                          │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ SelectTask{selectionMap={name=name}, selectAll=false, tableAliases={instances=instances}}                                                                                        │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@vania-pooh
Copy link
Member Author

But does not work for initial SQL:

perspective>explain select i.name, p.name from instances i, projects p where i.project_id = p.id OR p.name = 'test';
Results contain 2 entries.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ task                                                                                                                                                                             │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DataSourceTask{dataSource=DataSource{tableAlias='null', leftDataSource=DataSource{tableAlias='i', leftDataSource=null, isNaturalJoin=false, joinType=null,                       │
│ condition=IndexBooleanExpression{fixedValueConditions={}, columnRelations=[]}, columns=[], rightDatasource=DataSource{tableAlias='p', leftDataSource=null, isNaturalJoin=false,  │
│ joinType=INNER, condition=IndexBooleanExpression{fixedValueConditions={name=[test]}, columnRelations=[ColumnRelation{i.project_id = p.id}]}, columns=[], rightDatasource=null,   │
│ type=INDEX_SCAN}, type=INDEX_SCAN}, isNaturalJoin=false, joinType=null, condition=null, columns=[], rightDatasource=null, type=PARENT}, tableAliases={p=projects, i=instances}}  │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ SelectTask{selectionMap={i.name=i.name, p.name=p.name}, selectAll=false, tableAliases={p=projects, i=instances}}                                                                 │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@vania-pooh vania-pooh changed the title Check whether fixed values with or queries are handled correctly Requests having expressions with or queries are handled incorrectly Oct 18, 2016
@vania-pooh
Copy link
Member Author

Same is true for TableScan:

perspective>explain select created  from instances where name REGEXP '123' or name REGEXP '345';
Results contain 3 entries.
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ task                                                                                                                                                                             │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ DataSourceTask{dataSource=DataSource{tableAlias='null', leftDataSource=DataSource{tableAlias='instances', leftDataSource=null, isNaturalJoin=false, joinType=null,               │
│ condition=null, columns=[], rightDatasource=null, type=TABLE_SCAN}, isNaturalJoin=false, joinType=null, condition=null, columns=[], rightDatasource=null, type=PARENT},          │
│ tableAliases={instances=instances}}                                                                                                                                              │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ FilterTask{condition=name REGEXP 123 && name REGEXP 345}                                                                                                                         │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ SelectTask{selectionMap={created=created}, selectAll=false, tableAliases={instances=instances}}                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@vania-pooh
Copy link
Member Author

Decided to move IndexScan part to #182 as it's a big feature. The rest is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant