Skip to content

*: support select from partition table#6642

Merged
tiancaiamao merged 29 commits intopingcap:masterfrom
tiancaiamao:table-partition
Jun 22, 2018
Merged

*: support select from partition table#6642
tiancaiamao merged 29 commits intopingcap:masterfrom
tiancaiamao:table-partition

Conversation

@tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented May 25, 2018

This PR is ready for review.

}

// locatePartition returns the partition ID of the input record.
func (t *Table) locatePartition(ctx sessionctx.Context, r []types.Datum) (int64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

We should store the expression in *Table in TableFromMeta.

@winoros
Copy link
Member

winoros commented May 25, 2018

Why not do this when converting to physical plan. It's strange to add a logical rule to this.

@tiancaiamao
Copy link
Contributor Author

Because I thought it's more difficult to do that, so I choose to modify logical plan.
Anyway, I agree that your idea is more natural. @winoros

@tiancaiamao tiancaiamao changed the title [WIP] Support INSERT/SELECT for table partition *: support select from partition table May 31, 2018
@tiancaiamao tiancaiamao removed the WIP label May 31, 2018
@tiancaiamao
Copy link
Contributor Author

This PR is ready for review.
I'll add config and some time in another PR, as this one is big enough.
PTAL @coocood @winoros

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @winoros

1 similar comment
@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @winoros

@coocood
Copy link
Member

coocood commented Jun 4, 2018

@tiancaiamao
Please add tests for the prunePartition method.

@tiancaiamao
Copy link
Contributor Author

Done. @coocood

return selectOnSomething(sel, ds)
}

var partitionExpr []expression.Expression
Copy link
Member

Choose a reason for hiding this comment

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

partitionExprs


// partitionTable is for those tables which implement partition.
type partitionTable interface {
PartitionExpr() []expression.Expression
Copy link
Member

Choose a reason for hiding this comment

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

PartitionExprs

selConds = sel.Conditions
}

col := partitionExprAccessColumn(partitionExpr[0])
Copy link
Member

Choose a reason for hiding this comment

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

check nil here instead of in canBePrune?

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @winoros

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @winoros @zz-jason

// select * from p3 where id < 30)
//
// tablePartition is here because it's easier to prune partition after predicate push down.
type tablePartition struct{}
Copy link
Member

Choose a reason for hiding this comment

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

s/tablePartition/partitionPrunning/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It not only does the partition pruning, but also the ast structure rewrite, so I think partitionPrunning is not very accurate

Copy link
Member

@coocood coocood Jun 14, 2018

Choose a reason for hiding this comment

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

s/tablePartition/partitionProcessor

return selectOnSomething(sel, lp)
}

func selectOnSomething(sel *LogicalSelection, lp LogicalPlan) (LogicalPlan, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can make all the functions this file to be a member function of tablePartition

@tiancaiamao
Copy link
Contributor Author

PTAL @shenli

1 similar comment
@tiancaiamao
Copy link
Contributor Author

PTAL @shenli

return len(r) == 0, nil
}

// partitionExprAccessColumn extracts the column which is visited by the partition expression.
Copy link
Member

Choose a reason for hiding this comment

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

s/visited/used/

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

4 similar comments
@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

/rebuild

@tiancaiamao
Copy link
Contributor Author

/run-mybatis-test
/run-sqllogic-test

@tiancaiamao
Copy link
Contributor Author

PTAL @shenli

@tiancaiamao tiancaiamao added status/all tests passed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 21, 2018
@tiancaiamao
Copy link
Contributor Author

PTAL @Shenlii

@shenli
Copy link
Member

shenli commented Jun 22, 2018

LGTM

@shenli shenli added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 22, 2018
@tiancaiamao tiancaiamao merged commit 284fe10 into pingcap:master Jun 22, 2018
@tiancaiamao tiancaiamao deleted the table-partition branch June 22, 2018 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants