use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.
the class LeftOuterUnnestMapOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
// Propagates all input variables that come from the outer branch.
PropagatingTypeEnvironment env = createPropagatingAllInputsTypeEnvironment(ctx);
env.getCorrelatedMissableVariableLists().add(variables);
// of (original type + null).
for (int i = 0; i < variables.size(); i++) {
env.setVarType(variables.get(i), ctx.getMissableTypeComputer().makeMissableType(variableTypes.get(i)));
}
return env;
}
use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.
the class GroupByOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
int n = 0;
for (ILogicalPlan p : nestedPlans) {
n += p.getRoots().size();
}
ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n];
int i = 0;
for (ILogicalPlan p : nestedPlans) {
for (Mutable<ILogicalOperator> r : p.getRoots()) {
envPointers[i] = new OpRefTypeEnvPointer(r, ctx);
i++;
}
}
IVariableTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
ILogicalOperator child = inputs.get(0).getValue();
IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(child);
for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getGroupByList()) {
ILogicalExpression expr = p.second.getValue();
if (p.first != null) {
env.setVarType(p.first, env2.getType(expr));
if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
LogicalVariable v1 = ((VariableReferenceExpression) expr).getVariableReference();
env.setVarType(v1, env2.getVarType(v1));
}
} else {
VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
LogicalVariable v2 = vre.getVariableReference();
env.setVarType(v2, env2.getVarType(v2));
}
}
for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getDecorList()) {
ILogicalExpression expr = p.second.getValue();
if (p.first != null) {
env.setVarType(p.first, env2.getType(expr));
} else {
VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
LogicalVariable v2 = vre.getVariableReference();
env.setVarType(v2, env2.getVarType(v2));
}
}
return env;
}
use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.
the class SelectOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
ITypeEnvPointer[] envPointers = new ITypeEnvPointer[1];
envPointers[0] = new OpRefTypeEnvPointer(inputs.get(0), ctx);
PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
if (condition.getValue().getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
return env;
}
AbstractFunctionCallExpression f1 = (AbstractFunctionCallExpression) condition.getValue();
if (!f1.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) {
return env;
}
ILogicalExpression a1 = f1.getArguments().get(0).getValue();
if (a1.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
if (f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) {
ILogicalExpression a2 = f2.getArguments().get(0).getValue();
if (a2.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
LogicalVariable var = ((VariableReferenceExpression) a2).getVariableReference();
env.getNonNullVariables().add(var);
}
}
}
return env;
}
use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.
the class LeftOuterUnnestOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
PropagatingTypeEnvironment env = createPropagatingAllInputsTypeEnvironment(ctx);
Object t = env.getType(expression.getValue());
// For the variables from the inner branch, the output type is the union
// of (original type + missing).
env.setVarType(variables.get(0), ctx.getMissableTypeComputer().makeMissableType(t));
if (positionalVariable != null) {
env.setVarType(positionalVariable, ctx.getMissableTypeComputer().makeMissableType(positionalVariableType));
}
// The produced variables of the this operator are missable because of the left outer semantics.
List<LogicalVariable> missableVars = new ArrayList<>();
missableVars.add(variables.get(0));
if (positionalVariable != null) {
missableVars.add(positionalVariable);
}
env.getCorrelatedMissableVariableLists().add(missableVars);
return env;
}
use of org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment in project asterixdb by apache.
the class NestedTupleSourceOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(final ITypingContext ctx) throws AlgebricksException {
ITypeEnvPointer[] p = new ITypeEnvPointer[1];
p[0] = new ITypeEnvPointer() {
@Override
public IVariableTypeEnvironment getTypeEnv() {
ILogicalOperator op = dataSourceReference.getValue().getInputs().get(0).getValue();
return ctx.getOutputTypeEnvironment(op);
}
};
return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, p);
}
Aggregations