Search in sources :

Example 11 with SQLSelectOrderByItem

use of com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem in project Mycat-Server by MyCATApache.

the class DruidSelectOracleParser method parseOrderAggGroupOracle.

protected void parseOrderAggGroupOracle(SQLStatement stmt, RouteResultset rrs, OracleSelectQueryBlock mysqlSelectQuery, SchemaConfig schema) {
    Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt, rrs, mysqlSelectQuery);
    OracleSelect oracleSelect = (OracleSelect) mysqlSelectQuery.getParent();
    if (oracleSelect.getOrderBy() != null) {
        List<SQLSelectOrderByItem> orderByItems = oracleSelect.getOrderBy().getItems();
        rrs.setOrderByCols(buildOrderByCols(orderByItems, aliaColumns));
    }
    isNeedParseOrderAgg = false;
}
Also used : OracleSelect(com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelect) SQLSelectOrderByItem(com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem)

Example 12 with SQLSelectOrderByItem

use of com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem in project Mycat-Server by MyCATApache.

the class DruidSelectParser method parseOrderAggGroupMysql.

protected void parseOrderAggGroupMysql(SchemaConfig schema, SQLStatement stmt, RouteResultset rrs, MySqlSelectQueryBlock mysqlSelectQuery) {
    MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
    stmt.accept(visitor);
    //		rrs.setGroupByCols((String[])visitor.getGroupByColumns().toArray());
    if (!isNeedParseOrderAgg) {
        return;
    }
    Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt, rrs, mysqlSelectQuery);
    //setOrderByCols
    if (mysqlSelectQuery.getOrderBy() != null) {
        List<SQLSelectOrderByItem> orderByItems = mysqlSelectQuery.getOrderBy().getItems();
        rrs.setOrderByCols(buildOrderByCols(orderByItems, aliaColumns));
    }
    isNeedParseOrderAgg = false;
}
Also used : MySqlSchemaStatVisitor(com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor) SQLSelectOrderByItem(com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem)

Aggregations

SQLSelectOrderByItem (com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem)12 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)3 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)3 SQLLimit (com.alibaba.druid.sql.ast.SQLLimit)1 SQLOrderingSpecification (com.alibaba.druid.sql.ast.SQLOrderingSpecification)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)1 SQLInSubQueryExpr (com.alibaba.druid.sql.ast.expr.SQLInSubQueryExpr)1 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)1 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)1 SQLConstraint (com.alibaba.druid.sql.ast.statement.SQLConstraint)1 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)1 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)1 SQLTableSource (com.alibaba.druid.sql.ast.statement.SQLTableSource)1 SQLUpdateSetItem (com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem)1 Limit (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.Limit)1 MySqlUpdateStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement)1 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)1 MySqlSchemaStatVisitor (com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor)1 OdpsSelectQueryBlock (com.alibaba.druid.sql.dialect.odps.ast.OdpsSelectQueryBlock)1