<p dir="auto">sharding-proxy version:4.0.0</p>
<p dir="auto">I insert some rows to sharding-proxy by my custom hash algorithm.</p>
<table role="table">
<thead>
<tr>
<th>person_id</th>
<th>name</th>
<th>last_update_time</th>
<th>account</th>
<th>which data node</th>
</tr>
</thead>
<tbody>
<tr>
<td>174fd27ef0f34fd5b9296f102ffdbd47</td>
<td>liuqiang</td>
<td>2020-02-12 20:47:10</td>
<td>3</td>
<td>ds_0</td>
</tr>
<tr>
<td>4295029899a64d1bbfc5b4d37b628f0c</td>
<td>wangwu</td>
<td>2020-02-12 20:28:22</td>
<td>2</td>
<td>ds_0</td>
</tr>
<tr>
<td>a672ba34d2f14f4d8e3ee9e8ccfd6ca5</td>
<td>liyi</td>
<td>2020-02-12 20:47:16</td>
<td>1</td>
<td>ds_0</td>
</tr>
<tr>
<td>bf840dc0eaf64f7a8a7493c3ffea8799</td>
<td>huangyao</td>
<td>2020-02-12 20:28:38</td>
<td>3</td>
<td>ds_0</td>
</tr>
<tr>
<td>c63b749e981a4dc6b4942b18978e0d08</td>
<td>lisi</td>
<td>2020-02-12 20:28:17</td>
<td>2</td>
<td>ds_0</td>
</tr>
<tr>
<td>e28da7bc9ddc45bdb2974041ed564fc3</td>
<td>zhangsan</td>
<td>2020-02-12 20:27:48</td>
<td>1</td>
<td>ds_0</td>
</tr>
<tr>
<td>f741d4fb69f14b869dac11e2889fe8c1</td>
<td>penggang</td>
<td>2020-02-12 20:28:34</td>
<td>3</td>
<td>ds_0</td>
</tr>
<tr>
<td>0596342115c14328b2b0458d0860a90c</td>
<td>lingang</td>
<td>2020-02-12 20:28:47</td>
<td>3</td>
<td>ds_1</td>
</tr>
<tr>
<td>2f8b95104c114cc5a8ab6bc86ef9ab62</td>
<td>luyang</td>
<td>2020-02-12 20:28:50</td>
<td>2</td>
<td>ds_1</td>
</tr>
<tr>
<td>4397392fb6274bf2bfcfc41ae1da55a5</td>
<td>tangliang</td>
<td>2020-02-12 20:28:42</td>
<td>1</td>
<td>ds_1</td>
</tr>
<tr>
<td>c57c358c49cc4da6b98477ad8a55db3f</td>
<td>help</td>
<td>2020-02-13 16:01:28</td>
<td>3</td>
<td>ds_1</td>
</tr>
<tr>
<td>d9edd130ab8241f6be4b96a12cdb0404</td>
<td>zhaoliu</td>
<td>2020-02-12 20:28:26</td>
<td>2</td>
<td>ds_1</td>
</tr>
<tr>
<td>f97ea21d03124aa8b59a23bad5585e81</td>
<td>wanger</td>
<td>2020-02-12 20:28:29</td>
<td>1</td>
<td>ds_1</td>
</tr>
</tbody>
</table>
<p dir="auto">then,I execute this SQL:</p>
<div class="highlight highlight-source-sql notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="select distinct account from tbperson;"><pre class="notranslate"><span class="pl-k">select distinct</span> account <span class="pl-k">from</span> tbperson;</pre></div>
<p dir="auto">result is :</p>
<table role="table">
<thead>
<tr>
<th>account</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>1</td>
</tr>
<tr>
<td>3</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>1</td>
</tr>
</tbody>
</table>
<p dir="auto">right result gonna be:</p>
<table role="table">
<thead>
<tr>
<th>account</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>1</td>
</tr>
</tbody>
</table>
<p dir="auto">look forward to your reply.</p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Before report a bug, make sure you have:</p>
<ul dir="auto">
<li>Searched open and closed <a href="https://github.com/apache/shardingsphere/issues">GitHub issues</a>.</li>
<li>Read documentation: <a href="https://shardingsphere.apache.org/document/current/en/overview" rel="nofollow">ShardingSphere Doc</a>.</li>
</ul>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response anymore and we cannot reproduce it on current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.0.0-RC1-SNAPSHOT</p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">Execute SQL correctly:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;"><pre class="notranslate"><code class="notranslate">select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;
</code></pre></div>
<h3 dir="auto">Actual behavior</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - Logic SQL: select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;
[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_0 ::: select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;
[ERROR] 2021-03-31 16:36:15.667 [ShardingSphere-Command-3] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.lang.IllegalStateException: Can not find owner from table.
	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.findTableNameFromSQL(TablesContext.java:118)
	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.findTableName(TablesContext.java:85)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditionValueMap(WhereClauseShardingConditionEngine.java:104)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:87)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.lambda$createShardingConditions$0(WhereClauseShardingConditionEngine.java:72)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:72)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createShardingConditions(ShardingSQLRouter.java:71)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:56)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47)
	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62)
	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52)
	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:93)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)"><pre class="notranslate"><code class="notranslate">[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - Logic SQL: select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;
[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
[INFO ] 2021-03-31 16:36:15.583 [ShardingSphere-Command-3] ShardingSphere-SQL - Actual SQL: ds_0 ::: select tranlist_dcdir,sum(tranlist_bale) as tranlist_total from tranlist group by tranlist_dcdir;
[ERROR] 2021-03-31 16:36:15.667 [ShardingSphere-Command-3] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.lang.IllegalStateException: Can not find owner from table.
	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.findTableNameFromSQL(TablesContext.java:118)
	at org.apache.shardingsphere.infra.binder.segment.table.TablesContext.findTableName(TablesContext.java:85)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditionValueMap(WhereClauseShardingConditionEngine.java:104)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:87)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.lambda$createShardingConditions$0(WhereClauseShardingConditionEngine.java:72)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine.createShardingConditions(WhereClauseShardingConditionEngine.java:72)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createShardingConditions(ShardingSQLRouter.java:71)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:56)
	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47)
	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62)
	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52)
	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:93)
	at org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:57)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>