Search in sources :

Example 1 with ExpressionGenerator

use of com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator in project streamline by hortonworks.

the class RuleParser method parseCondition.

private Condition parseCondition(SqlSelect sqlSelect) {
    Condition condition = null;
    SqlNode where = sqlSelect.getWhere();
    if (where != null) {
        ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs);
        condition = new Condition(where.accept(exprGenerator));
        referredUdfs.addAll(exprGenerator.getReferredUdfs());
    }
    LOG.debug("Condition {}", condition);
    return condition;
}
Also used : Condition(com.hortonworks.streamline.streams.layout.component.rule.expression.Condition) SqlNode(org.apache.calcite.sql.SqlNode) ExpressionGenerator(com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator)

Example 2 with ExpressionGenerator

use of com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator in project streamline by hortonworks.

the class RuleParser method parseProjection.

private Projection parseProjection(SqlSelect sqlSelect) {
    Projection projection;
    ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs);
    ExpressionList exprList = (ExpressionList) sqlSelect.getSelectList().accept(exprGenerator);
    if (exprList.getExpressions().size() == 1 && exprList.getExpressions().get(0) == STAR) {
        projection = null;
    } else {
        projection = new Projection(exprList.getExpressions());
    }
    referredUdfs.addAll(exprGenerator.getReferredUdfs());
    LOG.debug("Projection {}", projection);
    return projection;
}
Also used : Projection(com.hortonworks.streamline.streams.layout.component.rule.expression.Projection) ExpressionList(com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionList) ExpressionGenerator(com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator)

Example 3 with ExpressionGenerator

use of com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator in project streamline by hortonworks.

the class RuleParser method parseGroupBy.

private GroupBy parseGroupBy(SqlSelect sqlSelect) {
    GroupBy groupBy = null;
    SqlNodeList sqlGroupBy = sqlSelect.getGroup();
    if (sqlGroupBy != null) {
        ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs);
        ExpressionList exprList = (ExpressionList) sqlGroupBy.accept(exprGenerator);
        groupBy = new GroupBy(exprList.getExpressions());
        referredUdfs.addAll(exprGenerator.getReferredUdfs());
    }
    LOG.debug("GroupBy {}", groupBy);
    return groupBy;
}
Also used : GroupBy(com.hortonworks.streamline.streams.layout.component.rule.expression.GroupBy) SqlNodeList(org.apache.calcite.sql.SqlNodeList) ExpressionList(com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionList) ExpressionGenerator(com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator)

Example 4 with ExpressionGenerator

use of com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator in project streamline by hortonworks.

the class RuleParser method parseHaving.

private Having parseHaving(SqlSelect sqlSelect) {
    Having having = null;
    SqlNode sqlHaving = sqlSelect.getHaving();
    if (sqlHaving != null) {
        ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs);
        having = new Having(sqlHaving.accept(exprGenerator));
        referredUdfs.addAll(exprGenerator.getReferredUdfs());
    }
    LOG.debug("Having {}", having);
    return having;
}
Also used : Having(com.hortonworks.streamline.streams.layout.component.rule.expression.Having) SqlNode(org.apache.calcite.sql.SqlNode) ExpressionGenerator(com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator)

Aggregations

ExpressionGenerator (com.hortonworks.streamline.streams.layout.component.rule.sql.ExpressionGenerator)4 ExpressionList (com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionList)2 SqlNode (org.apache.calcite.sql.SqlNode)2 Condition (com.hortonworks.streamline.streams.layout.component.rule.expression.Condition)1 GroupBy (com.hortonworks.streamline.streams.layout.component.rule.expression.GroupBy)1 Having (com.hortonworks.streamline.streams.layout.component.rule.expression.Having)1 Projection (com.hortonworks.streamline.streams.layout.component.rule.expression.Projection)1 SqlNodeList (org.apache.calcite.sql.SqlNodeList)1