<p dir="auto">When I follow the configuration below it is invalid<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/45256940/136534807-f734eb18-f867-4560-b53c-b953762acfc0.png"><img src="https://user-images.githubusercontent.com/45256940/136534807-f734eb18-f867-4560-b53c-b953762acfc0.png" alt="image" style="max-width: 100%;"></a><br>
Must be configured below the table to take effect<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/45256940/136535042-257f4723-4eab-406f-b922-28b3864f20ca.png"><img src="https://user-images.githubusercontent.com/45256940/136535042-257f4723-4eab-406f-b922-28b3864f20ca.png" alt="image" style="max-width: 100%;"></a></p>
<h2 dir="auto">Bug Report</h2>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">3.0.0</p>
<h3 dir="auto">Which project did you use? Sharding-JDBC or Sharding-Proxy?</h3>
<p dir="auto">Sharding-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">I have a logic table 't' with 2 shards, actual table are 't_0' and 't_1'.<br>
When I excute "select code from t group by code" on Sharding-Proxy-3.0.0,<br>
it should returns code without duplicate.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">but in fact, it returns duplicate records.</p>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">My backend db is mysql5.7.<br>
COLLATE is 'utf8mb4_unicode_ci'.</p>
<p dir="auto">The group-by merger may add 'order by code' clause for using stream merge,<br>
and the result set is sorted by case insensitive.<br>
But the merger compares value with case sensitive(because use java compareTo method).</p>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<h4 dir="auto">sharding rule:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  tables:
    t:
      actualDataNodes: ds_${0}.t_${0..1}
      tableStrategy:
        inline:
          shardingColumn: id
          algorithmExpression: t_${id % 2}"><pre class="notranslate"><code class="notranslate">  tables:
    t:
      actualDataNodes: ds_${0}.t_${0..1}
      tableStrategy:
        inline:
          shardingColumn: id
          algorithmExpression: t_${id % 2}
</code></pre></div>
<h4 dir="auto">prepare sql script:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CREATE TABLE `t_0` (
	`id` INT NOT NULL,
	`code` VARCHAR(40) NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8mb4_unicode_ci'
;
CREATE TABLE `t_1` (
	`id` INT NOT NULL,
	`code` VARCHAR(40) NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8mb4_unicode_ci'
;
insert into t values (11, '11035801128253');
insert into t values (13, '110358011282f5');
insert into t values (15, '110358011282G1');
insert into t values (17, '110358011282H5');
insert into t values (19, '110358011282T4');
insert into t values (21, '110358011282U5');
insert into t values (23, '110358011282z1');
insert into t values (22, '110358011282D4');
insert into t values (24, '110358011282E9');
insert into t values (26, '110358011282h8');
insert into t values (28, '110358011282I0');
insert into t values (30, '110358011282l1');
insert into t values (32, '110358011282O7');
insert into t values (34, '110358011282P0');
insert into t values (36, '110358011282T4');
insert into t values (38, '110358011282w6');


mysql&gt; select 't_0' as tab, code from t_0;
+------+----------------+
| tab  | code           |
+------+----------------+
| t_0  | 110358011282D4 |
| t_0  | 110358011282E9 |
| t_0  | 110358011282h8 |
| t_0  | 110358011282I0 |
| t_0  | 110358011282l1 |
| t_0  | 110358011282O7 |
| t_0  | 110358011282P0 |
| t_0  | 110358011282T4 |
| t_0  | 110358011282w6 |
+------+----------------+
9 rows in set (0.00 sec)

mysql&gt; select 't_1' as tab, code from t_1;
+------+----------------+
| tab  | code           |
+------+----------------+
| t_1  | 11035801128253 |
| t_1  | 110358011282f5 |
| t_1  | 110358011282G1 |
| t_1  | 110358011282H5 |
| t_1  | 110358011282T4 |
| t_1  | 110358011282U5 |
| t_1  | 110358011282z1 |
+------+----------------+
7 rows in set (0.00 sec)"><pre class="notranslate"><code class="notranslate">CREATE TABLE `t_0` (
	`id` INT NOT NULL,
	`code` VARCHAR(40) NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8mb4_unicode_ci'
;
CREATE TABLE `t_1` (
	`id` INT NOT NULL,
	`code` VARCHAR(40) NOT NULL,
	PRIMARY KEY (`id`)
)
COLLATE='utf8mb4_unicode_ci'
;
insert into t values (11, '11035801128253');
insert into t values (13, '110358011282f5');
insert into t values (15, '110358011282G1');
insert into t values (17, '110358011282H5');
insert into t values (19, '110358011282T4');
insert into t values (21, '110358011282U5');
insert into t values (23, '110358011282z1');
insert into t values (22, '110358011282D4');
insert into t values (24, '110358011282E9');
insert into t values (26, '110358011282h8');
insert into t values (28, '110358011282I0');
insert into t values (30, '110358011282l1');
insert into t values (32, '110358011282O7');
insert into t values (34, '110358011282P0');
insert into t values (36, '110358011282T4');
insert into t values (38, '110358011282w6');


mysql&gt; select 't_0' as tab, code from t_0;
+------+----------------+
| tab  | code           |
+------+----------------+
| t_0  | 110358011282D4 |
| t_0  | 110358011282E9 |
| t_0  | 110358011282h8 |
| t_0  | 110358011282I0 |
| t_0  | 110358011282l1 |
| t_0  | 110358011282O7 |
| t_0  | 110358011282P0 |
| t_0  | 110358011282T4 |
| t_0  | 110358011282w6 |
+------+----------------+
9 rows in set (0.00 sec)

mysql&gt; select 't_1' as tab, code from t_1;
+------+----------------+
| tab  | code           |
+------+----------------+
| t_1  | 11035801128253 |
| t_1  | 110358011282f5 |
| t_1  | 110358011282G1 |
| t_1  | 110358011282H5 |
| t_1  | 110358011282T4 |
| t_1  | 110358011282U5 |
| t_1  | 110358011282z1 |
+------+----------------+
7 rows in set (0.00 sec)
</code></pre></div>
<h4 dir="auto">execute result  ( duplicate code is 110358011282T4 .)</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mysql&gt; select code from t group by code;
+----------------+
| code           |
+----------------+
| 11035801128253 |
| 110358011282D4 |
| 110358011282E9 |
| 110358011282f5 |
| 110358011282G1 |
| 110358011282H5 |
| 110358011282T4 |
| 110358011282U5 |
| 110358011282h8 |
| 110358011282I0 |
| 110358011282l1 |
| 110358011282O7 |
| 110358011282P0 |
| 110358011282T4 |
| 110358011282w6 |
| 110358011282z1 |
+----------------+
16 rows in set (0.01 sec)"><pre class="notranslate"><code class="notranslate">mysql&gt; select code from t group by code;
+----------------+
| code           |
+----------------+
| 11035801128253 |
| 110358011282D4 |
| 110358011282E9 |
| 110358011282f5 |
| 110358011282G1 |
| 110358011282H5 |
| 110358011282T4 |
| 110358011282U5 |
| 110358011282h8 |
| 110358011282I0 |
| 110358011282l1 |
| 110358011282O7 |
| 110358011282P0 |
| 110358011282T4 |
| 110358011282w6 |
| 110358011282z1 |
+----------------+
16 rows in set (0.01 sec)
</code></pre></div>
<p dir="auto">I tried following SQL then I got right result.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="mysql&gt; select max(code) from t group by upper(code);
+----------------+
| max(code)      |
+----------------+
| 11035801128253 |
| 110358011282D4 |
| 110358011282E9 |
| 110358011282f5 |
| 110358011282G1 |
| 110358011282H5 |
| 110358011282h8 |
| 110358011282I0 |
| 110358011282l1 |
| 110358011282O7 |
| 110358011282P0 |
| 110358011282T4 |
| 110358011282U5 |
| 110358011282w6 |
| 110358011282z1 |
+----------------+
15 rows in set (0.01 sec)
"><pre class="notranslate"><code class="notranslate">mysql&gt; select max(code) from t group by upper(code);
+----------------+
| max(code)      |
+----------------+
| 11035801128253 |
| 110358011282D4 |
| 110358011282E9 |
| 110358011282f5 |
| 110358011282G1 |
| 110358011282H5 |
| 110358011282h8 |
| 110358011282I0 |
| 110358011282l1 |
| 110358011282O7 |
| 110358011282P0 |
| 110358011282T4 |
| 110358011282U5 |
| 110358011282w6 |
| 110358011282z1 |
+----------------+
15 rows in set (0.01 sec)

</code></pre></div>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>