<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/apache/shardingsphere/blob/1ea6d35c6a2deacb6e148158c6ac4adc6c60ef38/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java#L73-L78">shardingsphere/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilder.java</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 73 to 78
      in
      <a data-pjax="true" class="commit-tease-sha" href="/apache/shardingsphere/commit/1ea6d35c6a2deacb6e148158c6ac4adc6c60ef38">1ea6d35</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L73" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="73"></td>
          <td id="LC73" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-smi">List</span>&lt;<span class="pl-smi">RouteMapper</span>&gt; <span class="pl-en">getRouteTableRouteMappers</span>(<span class="pl-k">final</span> <span class="pl-smi">Collection</span>&lt;<span class="pl-smi">RouteMapper</span>&gt; <span class="pl-s1">tableMappers</span>) { </td>
        </tr>

        <tr class="border-0">
          <td id="L74" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="74"></td>
          <td id="LC74" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> (<span class="pl-c1">null</span> == <span class="pl-s1">tableMappers</span>) { </td>
        </tr>

        <tr class="border-0">
          <td id="L75" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="75"></td>
          <td id="LC75" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-k">return</span> <span class="pl-smi">Collections</span>.<span class="pl-en">emptyList</span>(); </td>
        </tr>

        <tr class="border-0">
          <td id="L76" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="76"></td>
          <td id="LC76" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L77" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="77"></td>
          <td id="LC77" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">return</span> <span class="pl-s1">tableMappers</span>.<span class="pl-en">stream</span>().<span class="pl-en">map</span>(<span class="pl-s1">routeMapper</span> -&gt; <span class="pl-k">new</span> <span class="pl-smi">RouteMapper</span>(<span class="pl-s1">routeMapper</span>.<span class="pl-en">getLogicName</span>(), <span class="pl-s1">routeMapper</span>.<span class="pl-en">getActualName</span>())).<span class="pl-en">collect</span>(<span class="pl-smi">Collectors</span>.<span class="pl-en">toList</span>()); </td>
        </tr>

        <tr class="border-0">
          <td id="L78" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="78"></td>
          <td id="LC78" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> } </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20503072/140038642-acffc9de-73b9-4733-b65b-a901c2734c05.png"><img src="https://user-images.githubusercontent.com/20503072/140038642-acffc9de-73b9-4733-b65b-a901c2734c05.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">They are equal but not the same instances. Could we reuse the instances?</p>
<h2 dir="auto">Bug Report</h2>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="	&lt;dependency&gt;
		&lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt;
		&lt;artifactId&gt;sharding-jdbc-core&lt;/artifactId&gt;
		&lt;version&gt;4.0.1&lt;/version&gt;
	&lt;/dependency&gt;"><pre class="notranslate"><code class="notranslate">	&lt;dependency&gt;
		&lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt;
		&lt;artifactId&gt;sharding-jdbc-core&lt;/artifactId&gt;
		&lt;version&gt;4.0.1&lt;/version&gt;
	&lt;/dependency&gt;
</code></pre></div>
<h3 dir="auto">Which project did you use? Sharding-JDBC or Sharding-Proxy?</h3>
<p dir="auto">Sharding-JDBC</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">sql execute ok, and return the result</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto"><code class="notranslate"> SQL: SELECT *         from test_user         where id = (             select test_user_id             from test_user_bind             where uid =?               and start_time   &lt;=   now()               and end_time &gt; now()             order by id desc             limit 1         ) Cause: java.lang.IllegalStateException: Must have sharding column with subquery. at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76) at sun.reflect.GeneratedMethodAccessor910.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ... 108 more Caused by: java.lang.IllegalStateException: Must have sharding column with subquery. at com.google.common.base.Preconditions.checkState(Preconditions.java:444) at org.apache.shardingsphere.core.route.router.sharding.ShardingRouter.checkSubqueryShardingValues(ShardingRouter.java:148) at org.apache.shardingsphere.core.route.router.sharding.ShardingRouter.route(ShardingRouter.java:109) at org.apache.shardingsphere.core.route.PreparedStatementRoutingEngine.route(PreparedStatementRoutingEngine.java:63) at org.apache.shardingsphere.core.PreparedQueryShardingEngine.route(PreparedQueryShardingEngine.java:59) at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:85) at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:68) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.shard(ShardingPreparedStatement.java:249) at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.execute(ShardingPreparedStatement.java:190) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.GeneratedMethodAccessor825.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy202.query(Unknown Source) at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:163) at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90) at sun.reflect.GeneratedMethodAccessor823.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy199.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ... 114 more</code></p>
<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>
<p dir="auto">The sharding yaml config：</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  ds_user: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db_user.url@
    user: @jdbc.db_user.user@
    password: @jdbc.db_user.password@
  ds0: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db0.url@
    user: @jdbc.db0.user@
    password: @jdbc.db0.password@
  ds1: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db1.url@
    user: @jdbc.db1.user@
    password: @jdbc.db1.password@
shardingRule:
  tables:
    zoom_user_bind:
      actualDataNodes: ds_user.zoom_user_bind
      databaseStrategy:
        none: {}
      tableStrategy:
        none: {}
    zoom_user:
      actualDataNodes: ds_user.zoom_user
      databaseStrategy:
        none: {}
      tableStrategy:
        none: {}

  defaultDataSourceName: ds_user
  defaultDatabaseStrategy:
    none: {}
  defaultTableStrategy:
    none: {}
props:
  sql.show: false```

### Example codes for reproduce this issue (such as a github link)."><pre lang="dataSources:" class="notranslate"><code class="notranslate">  ds_user: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db_user.url@
    user: @jdbc.db_user.user@
    password: @jdbc.db_user.password@
  ds0: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db0.url@
    user: @jdbc.db0.user@
    password: @jdbc.db0.password@
  ds1: !!com.mchange.v2.c3p0.ComboPooledDataSource
    driverClass: @jdbc.driverClassName@
    jdbcUrl: @jdbc.db1.url@
    user: @jdbc.db1.user@
    password: @jdbc.db1.password@
shardingRule:
  tables:
    zoom_user_bind:
      actualDataNodes: ds_user.zoom_user_bind
      databaseStrategy:
        none: {}
      tableStrategy:
        none: {}
    zoom_user:
      actualDataNodes: ds_user.zoom_user
      databaseStrategy:
        none: {}
      tableStrategy:
        none: {}

  defaultDataSourceName: ds_user
  defaultDatabaseStrategy:
    none: {}
  defaultTableStrategy:
    none: {}
props:
  sql.show: false```

### Example codes for reproduce this issue (such as a github link).
</code></pre></div>