use of org.apache.asterix.lang.common.expression.RecordConstructor in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(RecordConstructor rc, VariableSubstitutionEnvironment env) throws CompilationException {
List<FieldBinding> oldFbs = rc.getFbList();
ArrayList<FieldBinding> newFbs = new ArrayList<>(oldFbs.size());
for (FieldBinding fb : oldFbs) {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = fb.getLeftExpr().accept(this, env);
Pair<ILangExpression, VariableSubstitutionEnvironment> p2 = fb.getRightExpr().accept(this, env);
FieldBinding fb2 = new FieldBinding((Expression) p1.first, (Expression) p2.first);
newFbs.add(fb2);
}
RecordConstructor newRc = new RecordConstructor(newFbs);
return new Pair<>(newRc, env);
}
use of org.apache.asterix.lang.common.expression.RecordConstructor in project asterixdb by apache.
the class SqlppExpressionToPlanTranslator method generateReturnExpr.
// Generates the return expression for a select clause.
private Expression generateReturnExpr(SelectClause selectClause, SelectBlock selectBlock) {
SelectRegular selectRegular = selectClause.getSelectRegular();
List<FieldBinding> fieldBindings = new ArrayList<>();
List<Projection> projections = selectRegular.getProjections();
for (Projection projection : projections) {
if (projection.star()) {
if (selectBlock.hasGroupbyClause()) {
fieldBindings.addAll(getGroupBindings(selectBlock.getGroupbyClause()));
} else if (selectBlock.hasFromClause()) {
fieldBindings.addAll(getFromBindings(selectBlock.getFromClause()));
}
} else {
fieldBindings.add(new FieldBinding(new LiteralExpr(new StringLiteral(projection.getName())), projection.getExpression()));
}
}
return new RecordConstructor(fieldBindings);
}
use of org.apache.asterix.lang.common.expression.RecordConstructor in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public RecordConstructor visit(RecordConstructor rc, Void arg) throws CompilationException {
List<FieldBinding> bindings = new ArrayList<>();
for (FieldBinding binding : rc.getFbList()) {
FieldBinding fb = new FieldBinding((Expression) binding.getLeftExpr().accept(this, arg), (Expression) binding.getRightExpr().accept(this, arg));
bindings.add(fb);
}
return new RecordConstructor(bindings);
}
Aggregations