Search in sources :

Example 11 with AstSelectList

use of com.developmentontheedge.sql.model.AstSelectList in project be5 by DevelopmentOnTheEdge.

the class ColumnsApplier method keepOnlyOutColumns.

public void keepOnlyOutColumns(AstBeSqlSubQuery subQuery) {
    List<String> outColumns = Arrays.asList(subQuery.getOutColumns().split(","));
    AstSelect select = (AstSelect) subQuery.getQuery().child(0);
    AstSelectList selectList = select.getSelectList();
    if (selectList.isAllColumns()) {
        throw new IllegalStateException("All columns not support " + selectList.getNodeContent());
    } else {
        for (int i = selectList.jjtGetNumChildren() - 1; i >= 0; i--) {
            AstDerivedColumn derivedColumn = (AstDerivedColumn) selectList.jjtGetChild(i);
            if (!outColumns.contains(derivedColumn.getAlias().replace("\"", ""))) {
                derivedColumn.remove();
            }
        }
    }
}
Also used : AstSelect(com.developmentontheedge.sql.model.AstSelect) AstSelectList(com.developmentontheedge.sql.model.AstSelectList) AstDerivedColumn(com.developmentontheedge.sql.model.AstDerivedColumn)

Aggregations

AstSelectList (com.developmentontheedge.sql.model.AstSelectList)11 AstSelect (com.developmentontheedge.sql.model.AstSelect)10 AstFrom (com.developmentontheedge.sql.model.AstFrom)8 AstIdentifierConstant (com.developmentontheedge.sql.model.AstIdentifierConstant)8 AstTableRef (com.developmentontheedge.sql.model.AstTableRef)8 AstDerivedColumn (com.developmentontheedge.sql.model.AstDerivedColumn)5 AstParenthesis (com.developmentontheedge.sql.model.AstParenthesis)5 AstQuery (com.developmentontheedge.sql.model.AstQuery)5 AstWhere (com.developmentontheedge.sql.model.AstWhere)5 AstFieldReference (com.developmentontheedge.sql.model.AstFieldReference)4 AstLimit (com.developmentontheedge.sql.model.AstLimit)4 SimpleNode (com.developmentontheedge.sql.model.SimpleNode)4 AstFunNode (com.developmentontheedge.sql.model.AstFunNode)3 AstWindowFunction (com.developmentontheedge.sql.model.AstWindowFunction)3 AstBetweenPredicate (com.developmentontheedge.sql.model.AstBetweenPredicate)2 AstWindowSpecification (com.developmentontheedge.sql.model.AstWindowSpecification)2 AstColumnList (com.developmentontheedge.sql.model.AstColumnList)1 AstCount (com.developmentontheedge.sql.model.AstCount)1 AstOrderBy (com.developmentontheedge.sql.model.AstOrderBy)1 AstValues (com.developmentontheedge.sql.model.AstValues)1