feature: `MonthMod` shard algorithm
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
implement ShardingAlgorithm interface.
type ShardingAlgorithm interface {
HasShardingKey(key string) bool
Shard(condition *KeyCondition) (Condition, error)
ShardRange(cond1, cond2 *KeyCondition) (Condition, error)
AllShards() Condition
AllowFullScan() bool
}
https://github.com/CECTC/dbpack/blob/0ae8c774106b58f5dbbfa045d4a8591fb913c929/pkg/cond/sharding_algorithm.go#L226
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
@dk-lockdown could you please explain with more details? 🙏 I was not clear for me, please man
@dk-lockdown could you please explain with more details? 🙏 I was not clear for me, please man
If a column of the table is of type date, and the sharding algorithm is sharded by month. When execute select * from t where day > 2020-01-05 and day < 2020-05-05, and the sharding key is day, the sharding algorithm is Month(day) mod 12, the sharding result will be calculated for January to May, so the sql will be rewritten as:
select * from t_1 where day > 2020-01-05 and day < 2020-05-05;
select * from t_2 where day > 2020-01-05 and day < 2020-05-05;
select * from t_3 where day > 2020-01-05 and day < 2020-05-05;
select * from t_4 where day > 2020-01-05 and day < 2020-05-05;
select * from t_5 where day > 2020-01-05 and day < 2020-05-05;
Then aggregate the query results.