Search in sources :

Example 11 with SQLLiteralExpr

use of com.alibaba.druid.sql.ast.expr.SQLLiteralExpr in project dble by actiontech.

the class ServerLoadDataInfileHandler method buildResultSet.

private RouteResultset buildResultSet(Map<String, LoadData> routeMap) {
    statement.setLocal(true);
    // druid will filter path, reset it now
    SQLLiteralExpr fn = new SQLCharExpr(fileName);
    statement.setFileName(fn);
    // replace IGNORE X LINES in SQL to avoid  IGNORING X LINE in every node.
    String srcStatement = this.ignoreLinesDelete(statement.toString());
    RouteResultset rrs = new RouteResultset(srcStatement, ServerParse.LOAD_DATA_INFILE_SQL);
    rrs.setLoadData(true);
    rrs.setStatement(srcStatement);
    rrs.setFinishedRoute(true);
    int size = routeMap.size();
    RouteResultsetNode[] routeResultsetNodes = new RouteResultsetNode[size];
    int index = 0;
    for (Map.Entry<String, LoadData> entry : routeMap.entrySet()) {
        RouteResultsetNode rrNode = new RouteResultsetNode(entry.getKey(), ServerParse.LOAD_DATA_INFILE_SQL, srcStatement);
        rrNode.setStatement(srcStatement);
        LoadData newLoadData = new LoadData();
        ObjectUtil.copyProperties(loadData, newLoadData);
        newLoadData.setLocal(true);
        LoadData loadData1 = entry.getValue();
        if (loadData1.getFileName() != null) {
            newLoadData.setFileName(loadData1.getFileName());
        } else {
            newLoadData.setData(loadData1.getData());
        }
        rrNode.setLoadData(newLoadData);
        routeResultsetNodes[index] = rrNode;
        index++;
    }
    rrs.setNodes(routeResultsetNodes);
    return rrs;
}
Also used : SQLLiteralExpr(com.alibaba.druid.sql.ast.expr.SQLLiteralExpr) SQLCharExpr(com.alibaba.druid.sql.ast.expr.SQLCharExpr) LoadData(com.actiontech.dble.sqlengine.mpp.LoadData) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) RouteResultset(com.actiontech.dble.route.RouteResultset)

Aggregations

SQLLiteralExpr (com.alibaba.druid.sql.ast.expr.SQLLiteralExpr)11 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)8 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)4 SQLName (com.alibaba.druid.sql.ast.SQLName)4 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)3 SQLObject (com.alibaba.druid.sql.ast.SQLObject)2 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)2 ParserException (com.alibaba.druid.sql.parser.ParserException)2 RouteResultset (io.mycat.route.RouteResultset)2 RouteResultsetNode (io.mycat.route.RouteResultsetNode)2 LoadData (io.mycat.sqlengine.mpp.LoadData)2 RouteResultset (com.actiontech.dble.route.RouteResultset)1 RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)1 LoadData (com.actiontech.dble.sqlengine.mpp.LoadData)1 SQLCommentHint (com.alibaba.druid.sql.ast.SQLCommentHint)1 SQLBooleanExpr (com.alibaba.druid.sql.ast.expr.SQLBooleanExpr)1 SQLMethodInvokeExpr (com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr)1 SQLNCharExpr (com.alibaba.druid.sql.ast.expr.SQLNCharExpr)1 SQLNumericLiteralExpr (com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr)1 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)1