set tidb_cost_model_version=1;
use test;
drop table if exists t;
create table t(
customer_id bigint,
id bigint,
expected_shard bigint unsigned,
computed_shard bigint unsigned null,
primary key (customer_id, id)
);
create index t_vitess_shard on t((vitess_hash(customer_id) >> 56));
explain format = 'brief' select customer_id from t where (vitess_hash(customer_id) >> 56) = x'd6' ORDER BY id;
id	estRows	task	access object	operator info
Projection	10.00	root		test.t.customer_id
└─Sort	10.00	root		test.t.id
  └─IndexLookUp	10.00	root		
    ├─IndexRangeScan(Build)	10.00	cop[tikv]	table:t, index:t_vitess_shard(vitess_hash(`customer_id`) >> 56)	range:[214,214], keep order:false, stats:pseudo
    └─TableRowIDScan(Probe)	10.00	cop[tikv]	table:t	keep order:false, stats:pseudo
explain format = 'brief' select id from t where (vitess_hash(customer_id) >> 56) IN (x'e0', x'e1') AND id BETWEEN 2 AND 5 ORDER BY id;
id	estRows	task	access object	operator info
Projection	0.50	root		test.t.id
└─Sort	0.50	root		test.t.id
  └─Projection	0.50	root		test.t.id, rightshift(vitess_hash(test.t.customer_id), 56)
    └─IndexLookUp	0.50	root		
      ├─IndexRangeScan(Build)	20.00	cop[tikv]	table:t, index:t_vitess_shard(vitess_hash(`customer_id`) >> 56)	range:[224,224], [225,225], keep order:false, stats:pseudo
      └─Selection(Probe)	0.50	cop[tikv]		ge(test.t.id, 2), le(test.t.id, 5)
        └─TableRowIDScan	20.00	cop[tikv]	table:t	keep order:false, stats:pseudo
explain format = 'brief' select hex(vitess_hash(1123)) from t;
id	estRows	task	access object	operator info
Projection	10000.00	root		31B565D41BDF8CA->Column#7
└─IndexReader	10000.00	root		index:IndexFullScan
  └─IndexFullScan	10000.00	cop[tikv]	table:t, index:t_vitess_shard(vitess_hash(`customer_id`) >> 56)	keep order:false, stats:pseudo
