class RouteService implements IRouteService {

    public ExecutePlan doRoute(String sql, Map<Integer, ParameterCommand> parameterCommand) {

        SqlType sqlType = SqlTypeUtil.getSqlType(sql);

        SqlParser parser = SqlParserFactory.getParser(sqlType);

        if (parser == null){
            return buildExecutePlanTypeNo(sql, null, sqlType);
        }

        // 解析结果
        ParseResult result = new ParseResult();

        // 初始化解析器
        parser.init(sql, buildParameters(parameterCommand));

        // 解析
        parser.parse(result);

        // 路由
        ExecutePlan plan = route(result.getTables(), result.getCalculateUnits(), sql, sqlType);

        // 改写plan中sql
        parser.changeSql(result, plan);

        return plan;
    }

}