use of org.apache.asterix.lang.common.expression.FieldBinding in project asterixdb by apache.
the class LangExpressionToPlanTranslator method visit.
@Override
public Pair<ILogicalOperator, LogicalVariable> visit(RecordConstructor rc, Mutable<ILogicalOperator> tupSource) throws CompilationException {
AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR));
LogicalVariable v1 = context.newVar();
AssignOperator a = new AssignOperator(v1, new MutableObject<>(f));
Mutable<ILogicalOperator> topOp = tupSource;
for (FieldBinding fb : rc.getFbList()) {
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = langExprToAlgExpression(fb.getLeftExpr(), topOp);
f.getArguments().add(new MutableObject<>(eo1.first));
topOp = eo1.second;
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = langExprToAlgExpression(fb.getRightExpr(), topOp);
f.getArguments().add(new MutableObject<>(eo2.first));
topOp = eo2.second;
}
a.getInputs().add(topOp);
return new Pair<>(a, v1);
}
use of org.apache.asterix.lang.common.expression.FieldBinding in project asterixdb by apache.
the class InlineColumnAliasVisitor method mapRecordConstructor.
private Map<Expression, Expression> mapRecordConstructor(RecordConstructor rc) {
Map<Expression, Expression> exprMap = new HashMap<>();
for (FieldBinding binding : rc.getFbList()) {
Expression leftExpr = binding.getLeftExpr();
// (e.g., foo.name AS name) in regular SQL SELECT.
if (leftExpr.getKind() != Kind.LITERAL_EXPRESSION) {
continue;
}
LiteralExpr literalExpr = (LiteralExpr) leftExpr;
if (literalExpr.getValue().getLiteralType() == Literal.Type.STRING) {
String fieldName = SqlppVariableUtil.toInternalVariableName(literalExpr.getValue().getStringValue());
exprMap.put(new VariableExpr(new VarIdentifier(fieldName)), binding.getRightExpr());
}
}
return exprMap;
}
use of org.apache.asterix.lang.common.expression.FieldBinding in project asterixdb by apache.
the class QueryPrintVisitor method visit.
@Override
public Void visit(RecordConstructor rc, Integer step) throws CompilationException {
out.println(skip(step) + "RecordConstructor [");
// fbList accept visitor
for (FieldBinding fb : rc.getFbList()) {
out.println(skip(step + 1) + "(");
fb.getLeftExpr().accept(this, step + 2);
out.println(skip(step + 2) + ":");
fb.getRightExpr().accept(this, step + 2);
out.println(skip(step + 1) + ")");
}
out.println(skip(step) + "]");
return null;
}
use of org.apache.asterix.lang.common.expression.FieldBinding 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.FieldBinding in project asterixdb by apache.
the class FreeVariableVisitor method visit.
@Override
public Void visit(RecordConstructor rc, Collection<VariableExpr> freeVars) throws CompilationException {
for (FieldBinding binding : rc.getFbList()) {
binding.getLeftExpr().accept(this, freeVars);
binding.getRightExpr().accept(this, freeVars);
}
return null;
}
Aggregations