Search in sources :

Example 1 with NonPropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment in project asterixdb by apache.

the class UnionAllOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    IVariableTypeEnvironment env = new NonPropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMetadataProvider());
    IVariableTypeEnvironment envLeft = ctx.getOutputTypeEnvironment(inputs.get(0).getValue());
    IVariableTypeEnvironment envRight = ctx.getOutputTypeEnvironment(inputs.get(1).getValue());
    if (envLeft == null) {
        throw new AlgebricksException("Left input types for union operator are not computed.");
    }
    for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> t : varMap) {
        Object typeFromLeft = getType(envLeft, t.first);
        Object typeFromRight = getType(envRight, t.second);
        if (typeFromLeft.equals(typeFromRight)) {
            env.setVarType(t.third, typeFromLeft);
        } else {
            env.setVarType(t.third, ctx.getConflictingTypeResolver().resolve(typeFromLeft, typeFromRight));
        }
    }
    return env;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) NonPropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Example 2 with NonPropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment in project asterixdb by apache.

the class UnnestMapOperator method computeOutputTypeEnvironment.

// When propagateInput is true,
// this operator propagates all input variables.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    IVariableTypeEnvironment env = null;
    if (propagateInput) {
        env = createPropagatingAllInputsTypeEnvironment(ctx);
    } else {
        env = new NonPropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMetadataProvider());
    }
    int n = variables.size();
    for (int i = 0; i < n; i++) {
        env.setVarType(variables.get(i), variableTypes.get(i));
    }
    return env;
}
Also used : NonPropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Example 3 with NonPropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment in project asterixdb by apache.

the class IntersectOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    IVariableTypeEnvironment typeEnv = ctx.getOutputTypeEnvironment(inputs.get(0).getValue());
    for (int i = 1; i < inputs.size(); i++) {
        checkTypeConsistency(typeEnv, inputVars.get(0), ctx.getOutputTypeEnvironment(inputs.get(i).getValue()), inputVars.get(i));
    }
    IVariableTypeEnvironment env = new NonPropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMetadataProvider());
    for (int i = 0; i < outputVars.size(); i++) {
        env.setVarType(outputVars.get(i), typeEnv.getVarType(inputVars.get(0).get(i)));
    }
    return typeEnv;
}
Also used : NonPropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Example 4 with NonPropagatingTypeEnvironment

use of org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment in project asterixdb by apache.

the class AggregateOperator method computeOutputTypeEnvironment.

@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
    IVariableTypeEnvironment env = new NonPropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMetadataProvider());
    IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(inputs.get(0).getValue());
    int n = variables.size();
    for (int i = 0; i < n; i++) {
        Object t = ctx.getExpressionTypeComputer().getType(expressions.get(i).getValue(), ctx.getMetadataProvider(), env2);
        env.setVarType(variables.get(i), t);
    }
    return env;
}
Also used : NonPropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment) IVariableTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)

Aggregations

IVariableTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)4 NonPropagatingTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment)4 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)1 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)1