not support count if, database will be the default , not the true
i has two databases; like 'comon' and 'user'; 'comon' as the default database; table 'tx_user' is in 'user' database.
SELECT count(IF(sex = 1 , TRUE , NULL)) AS maleCount FROM tx_user; can be explain to comon.tx_user;
@trojanliu thanks for you issue, is 'user' database for sharding ? please show your sharding rule.
<sharding:data-source id="myDataSource">
<sharding:sharding-rule data-source-names="common,user"
default-data-source-name="common"
default-database-strategy-ref="noneStrategy"
default-table-strategy-ref="noneStrategy">
<sharding:table-rules>
<sharding:table-rule logic-table="tx_user" actual-data-nodes="user.tx_user" generate-key-column-name="uid"/>
</sharding:table-rules>
</sharding:sharding-rule>
<sharding:props>
<prop key="sql.show">${hibernate.show_sql}</prop>
<prop key="executor.size">2</prop>
</sharding:props>
</sharding:data-source>
<sharding:table-rule logic-table="tx_user" actual-data-nodes="user.tx_user" generate-key-column-name="uid"/>
tx_user is a single table. no databases rule , no tables rule .
@trojanliu which shardingsphere version do you use? have a try using dev branch code , i use sharding-spring-namespace-mybatis-example , shardingsphere code is the lastest, result of routing is correct.See the following figures for the results.

i use 3.1.0. dev branch code is ok? i try it later .
use this version 4.0.0-RC1-SNAPSHOT, compile it by yourself using source code,,just mvn clean install in root dir of project


IN VERSION 3.1.0
if sql is 'SELECT count(IF(sex = 1 , TRUE , NULL)) AS maleCount FROM tx_user;'
it will parsing stop at if.
AND tablename is not parsing, so it use the default database;