Skip to content

*: fix copr push down test (tidb#36415)#160

Merged
breezewish merged 1 commit into
tikv:masterfrom
solotzg:patch-1
Jul 22, 2022
Merged

*: fix copr push down test (tidb#36415)#160
breezewish merged 1 commit into
tikv:masterfrom
solotzg:patch-1

Conversation

@solotzg
Copy link
Copy Markdown
Contributor

@solotzg solotzg commented Jul 22, 2022

Wait for tidb#36415
Verified in https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_integration_copr_test/detail/tidb_ghpr_integration_copr_test/9781/pipeline/88

Minimal reproduce step

drop table if exists cop_test;

create table cop_test (
    `col_year` year(4),
    `col_varbinary_32` varbinary(32)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

insert into cop_test values(NULL, '0'), (0000, NULL), (2004, NULL), (NULL, 'cbuxpgpjkkrzbrmcqhkctuhuzdvqqirt'), 
(2004, 'kcjvgqaoeycfzskxnknyyqdjlcbuxpgp'), (2014, '0'), (2008, '-1331298304'), (2007, '707461120'), (0000, '59506688');

SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;

What did you expect to see?

MySQL

mysql> SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1;
+------+
| f1   |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
|    0 |
|    0 |
|   -0 |
|    0 |
|    0 |
+------+
mysql> SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;
+------+
| f1   |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
|    0 |
|    0 |
|   -0 |
+------+

What did you see instead

TiKV return unstable sort result when using LIMIT()

MySQL [test]> SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1;
+------+
| f1   |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
|    0 |
|    0 |
|   -0 |
|    0 |
|    0 |
+------+

MySQL [test]> explain SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;
+----------------------------------+---------+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                               | estRows | task      | access object  | operator info                                                                                                                                                                                   |
+----------------------------------+---------+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_6                     | 7.00    | root      |                | mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY))->Column#4                                                         |
| └─Projection_13                  | 7.00    | root      |                | test.cop_test.col_year, test.cop_test.col_varbinary_32                                                                                                                                          |
|   └─TopN_7                       | 7.00    | root      |                | Column#5, offset:0, count:7                                                                                                                                                                     |
|     └─Projection_14              | 7.00    | root      |                | test.cop_test.col_year, test.cop_test.col_varbinary_32, mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY))->Column#5 |
|       └─TableReader_12           | 7.00    | root      |                | data:TopN_11                                                                                                                                                                                    |
|         └─TopN_11                | 7.00    | cop[tikv] |                | mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY)), offset:0, count:7                                                |
|           └─TableFullScan_10     | 9.00    | cop[tikv] | table:cop_test | keep order:false, stats:pseudo                                                                                                                                                                  |
+----------------------------------+---------+-----------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

MySQL [test]> SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;
+------+
| f1   |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
|    0 |
|   -0 |
|    0 |
+------+

MySQL [test]> explain analyze SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;
+----------------------------------+---------+---------+-----------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+
| id                               | estRows | actRows | task      | access object  | execution info                                                                                                                                                                           | operator info                                                                                                                                                                                   | memory     | disk |
+----------------------------------+---------+---------+-----------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+
| Projection_6                     | 7.00    | 7       | root      |                | time:1.05ms, loops:2, Concurrency:OFF                                                                                                                                                    | mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY))->Column#4                                                         | 1016 Bytes | N/A  |
| └─Projection_13                  | 7.00    | 7       | root      |                | time:1.01ms, loops:2, Concurrency:OFF                                                                                                                                                    | test.cop_test.col_year, test.cop_test.col_varbinary_32                                                                                                                                          | 1.36 KB    | N/A  |
|   └─TopN_7                       | 7.00    | 7       | root      |                | time:1ms, loops:2                                                                                                                                                                        | Column#5, offset:0, count:7                                                                                                                                                                     | 867 Bytes  | N/A  |
|     └─Projection_14              | 7.00    | 7       | root      |                | time:986.5µs, loops:2, Concurrency:OFF                                                                                                                                                   | test.cop_test.col_year, test.cop_test.col_varbinary_32, mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY))->Column#5 | 1016 Bytes | N/A  |
|       └─TableReader_12           | 7.00    | 7       | root      |                | time:906.3µs, loops:2, cop_task: {num: 1, max: 821.7µs, proc_keys: 9, rpc_num: 1, rpc_time: 784.1µs, copr_cache_hit_ratio: 0.00, distsql_concurrency: 15}                                | data:TopN_11                                                                                                                                                                                    | 670 Bytes  | N/A  |
|         └─TopN_11                | 7.00    | 7       | cop[tikv] |                | tikv_task:{time:0s, loops:1}, scan_detail: {total_process_keys: 9, total_process_keys_size: 445, total_keys: 10, get_snapshot_time: 38.9µs, rocksdb: {key_skipped_count: 9, block: {}}}  | mul(cast(rightshift(0, test.cop_test.col_year), double UNSIGNED BINARY), cast(test.cop_test.col_varbinary_32, double BINARY)), offset:0, count:7                                                | N/A        | N/A  |
|           └─TableFullScan_10     | 9.00    | 9       | cop[tikv] | table:cop_test | tikv_task:{time:0s, loops:1}                                                                                                                                                             | keep order:false, stats:pseudo                                                                                                                                                                  | N/A        | N/A  |
+----------------------------------+---------+---------+-----------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------+

Use unistore

use unistore and get current result

MySQL [test]> SELECT ( 0 >> `col_year` ) * `col_varbinary_32` as f1 FROM cop_test order by f1 limit 7;
+------+
| f1   |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
|    0 |
|    0 |
|   -0 |
+------+

Signed-off-by: root <root@localhost.localdomain>
@solotzg
Copy link
Copy Markdown
Contributor Author

solotzg commented Jul 22, 2022

/run-all-tests

@breezewish breezewish merged commit 8fd3068 into tikv:master Jul 22, 2022
@solotzg solotzg deleted the patch-1 branch July 22, 2022 07:48
@zanmato1984
Copy link
Copy Markdown

Need to cherry-pick to release-6.2, which doesn't exist yet. @solotzg

@solotzg solotzg mentioned this pull request Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants