use of com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionTranslator in project streamline by hortonworks.
the class StormSqlExpression method handleProjection.
private void handleProjection() {
if (projection != null) {
for (Expression expr : projection.getExpressions()) {
ExpressionTranslator translator = new StormSqlExpressionTranslator();
expr.accept(translator);
stormSqlFields.addAll(translator.getFields());
functions.addAll(translator.getFunctions());
aggregateFunctions.addAll(translator.getAggregateFunctions());
projectedFields.add(translator.getTranslatedExpression());
if (!translator.getAliases().isEmpty()) {
outputFields.add(translator.getAliases().get(0));
} else {
outputFields.add(translator.getUnquotedTranslatedExpression());
}
}
}
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionTranslator in project streamline by hortonworks.
the class StormSqlExpression method handleGroupByHaving.
private void handleGroupByHaving() {
if (groupBy != null) {
List<String> groupByExpressions = new ArrayList<>();
for (Expression expr : groupBy.getExpressions()) {
ExpressionTranslator groupByTranslator = new StormSqlExpressionTranslator();
expr.accept(groupByTranslator);
stormSqlFields.addAll(groupByTranslator.getFields());
groupByFields.addAll(groupByTranslator.getFields());
functions.addAll(groupByTranslator.getFunctions());
groupByExpressions.add(groupByTranslator.getTranslatedExpression());
}
groupByExpression = Joiner.on(",").join(groupByExpressions);
if (having != null) {
ExpressionTranslator havingTranslator = new StormSqlExpressionTranslator();
having.getExpression().accept(havingTranslator);
stormSqlFields.addAll(havingTranslator.getFields());
functions.addAll(havingTranslator.getFunctions());
aggregateFunctions.addAll(havingTranslator.getAggregateFunctions());
havingExpression = havingTranslator.getTranslatedExpression();
LOG.debug("Built expression [{}] for having [{}]", havingExpression, having);
}
}
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.ExpressionTranslator in project streamline by hortonworks.
the class StormSqlExpression method handleFilter.
private void handleFilter() {
if (condition != null) {
ExpressionTranslator conditionTranslator = new StormSqlExpressionTranslator();
condition.getExpression().accept(conditionTranslator);
stormSqlFields.addAll(conditionTranslator.getFields());
if (!conditionTranslator.getAggregateFunctions().isEmpty()) {
throw new IllegalArgumentException("Cannot have aggregate functions filter condition.");
}
functions.addAll(conditionTranslator.getFunctions());
expression = conditionTranslator.getTranslatedExpression();
LOG.debug("Built expression [{}] for filter condition [{}]", expression, condition);
}
}
Aggregations