Search in sources :

Example 1 with DruidParser

use of com.actiontech.dble.route.parser.druid.DruidParser in project dble by actiontech.

the class DefaultRouteStrategy method routeNormalSqlWithAST.

@Override
public RouteResultset routeNormalSqlWithAST(SchemaConfig schema, String originSql, RouteResultset rrs, LayerCachePool cachePool, ServerConnection sc) throws SQLException {
    SQLStatement statement = parserSQL(originSql);
    sc.getSession2().endParse();
    DruidParser druidParser = DruidParserFactory.create(statement, rrs.getSqlType());
    return RouterUtil.routeFromParser(druidParser, schema, rrs, statement, originSql, cachePool, new ServerSchemaStatVisitor(), sc);
}
Also used : ServerSchemaStatVisitor(com.actiontech.dble.route.parser.druid.ServerSchemaStatVisitor) DruidParser(com.actiontech.dble.route.parser.druid.DruidParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 2 with DruidParser

use of com.actiontech.dble.route.parser.druid.DruidParser in project dble by actiontech.

the class MergeBuilder method constructByStatement.

public RouteResultset constructByStatement(String sql, SQLSelectStatement select) throws SQLException {
    ServerSchemaStatVisitor visitor = new ServerSchemaStatVisitor();
    DruidParser druidParser = new DruidSingleUnitSelectParser();
    RouteResultset rrs = new RouteResultset(sql, ServerParse.SELECT);
    LayerCachePool pool = DbleServer.getInstance().getRouterService().getTableId2DataNodeCache();
    SchemaConfig schemaConfig = schemaConfigMap.get(node.getReferedTableNodes().get(0).getSchema());
    return RouterUtil.routeFromParser(druidParser, schemaConfig, rrs, select, sql, pool, visitor, session.getSource());
}
Also used : DruidSingleUnitSelectParser(com.actiontech.dble.route.parser.druid.impl.DruidSingleUnitSelectParser) ServerSchemaStatVisitor(com.actiontech.dble.route.parser.druid.ServerSchemaStatVisitor) SchemaConfig(com.actiontech.dble.config.model.SchemaConfig) DruidParser(com.actiontech.dble.route.parser.druid.DruidParser) LayerCachePool(com.actiontech.dble.cache.LayerCachePool) RouteResultset(com.actiontech.dble.route.RouteResultset)

Aggregations

DruidParser (com.actiontech.dble.route.parser.druid.DruidParser)2 ServerSchemaStatVisitor (com.actiontech.dble.route.parser.druid.ServerSchemaStatVisitor)2 LayerCachePool (com.actiontech.dble.cache.LayerCachePool)1 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)1 RouteResultset (com.actiontech.dble.route.RouteResultset)1 DruidSingleUnitSelectParser (com.actiontech.dble.route.parser.druid.impl.DruidSingleUnitSelectParser)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1