@Override
    public boolean decide(final SelectStatementContext selectStatementContext, final List<Object> parameters,
                          final RuleMetaData globalRuleMetaData, final ShardingSphereDatabase database, final ShardingRule rule, final Collection<DataNode> includedDataNodes) {
        Collection<String> tableNames = rule.getShardingLogicTableNames(selectStatementContext.getTablesContext().getTableNames());
        if (tableNames.isEmpty()) {
            return false;
        }
        includedDataNodes.addAll(getTableDataNodes(rule, tableNames, database));
        if (selectStatementContext.isContainsSubquery() || selectStatementContext.isContainsHaving()
                || selectStatementContext.isContainsCombine() || selectStatementContext.isContainsPartialDistinctAggregation()) {
            return true;
        }
        if (!selectStatementContext.isContainsJoinQuery() || rule.isAllTablesInSameDataSource(tableNames)) {
            return false;
        }
        if (1 == tableNames.size() && selectStatementContext.isContainsJoinQuery() && !rule.isAllBindingTables(database, selectStatementContext, tableNames)) {
            return true;
        }
        return tableNames.size() > 1 && !rule.isAllBindingTables(database, selectStatementContext, tableNames);
    }
@Test
    void assertDecideWhenContainsSameShardingCondition() {
        SelectStatementContext select = createStatementContext();
        when(select.isContainsSubquery()).thenReturn(true);
        Collection<DataNode> includedDataNodes = new HashSet<>();
        ShardingRule shardingRule = createShardingRule();
        assertTrue(new ShardingSQLFederationDecider().decide(select, Collections.emptyList(), mock(RuleMetaData.class), createDatabase(shardingRule), shardingRule, includedDataNodes));
        assertThat(includedDataNodes.size(), is(4));
    }