*: support select from partition table#6642
Conversation
table/tables/tables.go
Outdated
| } | ||
|
|
||
| // locatePartition returns the partition ID of the input record. | ||
| func (t *Table) locatePartition(ctx sessionctx.Context, r []types.Datum) (int64, error) { |
There was a problem hiding this comment.
We should store the expression in *Table in TableFromMeta.
|
Why not do this when converting to physical plan. It's strange to add a logical rule to this. |
|
Because I thought it's more difficult to do that, so I choose to modify logical plan. |
18bfefc to
2340a80
Compare
1 similar comment
|
@tiancaiamao |
38e821c to
018aa65
Compare
|
Done. @coocood |
plan/rule_table_partition.go
Outdated
| return selectOnSomething(sel, ds) | ||
| } | ||
|
|
||
| var partitionExpr []expression.Expression |
plan/rule_table_partition.go
Outdated
|
|
||
| // partitionTable is for those tables which implement partition. | ||
| type partitionTable interface { | ||
| PartitionExpr() []expression.Expression |
plan/rule_table_partition.go
Outdated
| selConds = sel.Conditions | ||
| } | ||
|
|
||
| col := partitionExprAccessColumn(partitionExpr[0]) |
There was a problem hiding this comment.
check nil here instead of in canBePrune?
plan/rule_table_partition.go
Outdated
| // select * from p3 where id < 30) | ||
| // | ||
| // tablePartition is here because it's easier to prune partition after predicate push down. | ||
| type tablePartition struct{} |
There was a problem hiding this comment.
s/tablePartition/partitionPrunning/?
There was a problem hiding this comment.
It not only does the partition pruning, but also the ast structure rewrite, so I think partitionPrunning is not very accurate
There was a problem hiding this comment.
s/tablePartition/partitionProcessor
plan/rule_table_partition.go
Outdated
| return selectOnSomething(sel, lp) | ||
| } | ||
|
|
||
| func selectOnSomething(sel *LogicalSelection, lp LogicalPlan) (LogicalPlan, error) { |
There was a problem hiding this comment.
I think we can make all the functions this file to be a member function of tablePartition
|
PTAL @shenli |
1 similar comment
|
PTAL @shenli |
plan/rule_partition_processor.go
Outdated
| return len(r) == 0, nil | ||
| } | ||
|
|
||
| // partitionExprAccessColumn extracts the column which is visited by the partition expression. |
|
/run-all-tests |
4 similar comments
|
/run-all-tests |
|
/run-all-tests |
|
/run-all-tests |
|
/run-all-tests |
|
/run-all-tests |
|
/run-all-tests |
|
/rebuild |
|
/run-mybatis-test |
|
PTAL @shenli |
|
PTAL @Shenlii |
|
LGTM |
This PR is ready for review.