Search in sources :

Example 6 with OpRefTypeEnvPointer

use of org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer 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;
}
Also used : PropagatingTypeEnvironment(org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ILogicalExpression(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression) VariableReferenceExpression(org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) OpRefTypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer) ITypeEnvPointer(org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)

Aggregations

ITypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer)6 OpRefTypeEnvPointer (org.apache.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer)6 PropagatingTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment)6 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)3 ILogicalExpression (org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression)2 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)2 ILogicalPlan (org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan)2 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)2 ArrayList (java.util.ArrayList)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)1 IVariableTypeEnvironment (org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment)1