Package org.apache.pig.newplan.logical.expression

Examples of org.apache.pig.newplan.logical.expression.LogicalExpression


        // Following section is moved from
        // newplan/logical/rules/DuplicateForEachColumnRewrite.transform()

        for (LogicalExpressionPlan expPlan : expPlansToInsertIdentity) {
            LogicalExpression oldRoot = (LogicalExpression)expPlan.getSources().get(0);
            UserFuncExpression userFuncExpression = new UserFuncExpression(expPlan, new FuncSpec(IdentityColumn.class.getName()));
            expPlan.connect(userFuncExpression, oldRoot);
        }
        expPlansToInsertIdentity.clear();
View Full Code Here


        List<Long> uidSeen = new ArrayList<Long>();

        for (int i=0;i<expPlans.size();i++) {
            LogicalExpressionPlan expPlan = expPlans.get(i);
            boolean flatten = flattens[i];
            LogicalExpression exp = (LogicalExpression)expPlan.getSources().get(0);
            if (exp.getFieldSchema()!=null) {
                if (flatten && (exp.getFieldSchema().type == DataType.BAG || exp.getFieldSchema().type == DataType.TUPLE)) {
                    List<LogicalFieldSchema> innerFieldSchemas = null;
                    if (exp.getFieldSchema().type == DataType.BAG) {
                        if (exp.getFieldSchema().schema!=null) {
                            if (exp.getFieldSchema().type == DataType.BAG) {
                                //  assert(fieldSchema.schema.size() == 1 && fieldSchema.schema.getField(0).type == DataType.TUPLE)
                                if (exp.getFieldSchema().schema.getField(0).schema!=null)
                                    innerFieldSchemas = exp.getFieldSchema().schema.getField(0).schema.getFields();
                            } else {
                                if (exp.getFieldSchema().schema!=null)
                                    innerFieldSchemas = exp.getFieldSchema().schema.getFields();
                            }
                        }
                    }
                    else { // DataType.TUPLE
                        if (exp.getFieldSchema().schema!=null)
                            innerFieldSchemas = exp.getFieldSchema().schema.getFields();
                    }
                    if (innerFieldSchemas != null) {
                        for (LogicalFieldSchema innerFieldSchema : innerFieldSchemas) {
                            long uid = innerFieldSchema.uid;
                            if (checkAndAdd(uid, uidSeen)) {
                                // Seen before
                                expPlansToInsertIdentity.add(expPlan);
                                break;
                            }
                        }
                    }
                }
                else {
                    long uid = exp.getFieldSchema().uid;
                    if (checkAndAdd(uid, uidSeen)) {
                        // Seen before
                        expPlansToInsertIdentity.add(expPlan);
                    }
                }
View Full Code Here

     * @param binOp
     * @throws FrontendException
     */
    private void addCastsToNumericBinExpression(BinaryExpression binOp)
    throws FrontendException {
        LogicalExpression lhs = binOp.getLhs() ;
        LogicalExpression rhs = binOp.getRhs() ;

        byte lhsType = lhs.getType() ;
        byte rhsType = rhs.getType() ;

        if ( DataType.isNumberType(lhsType) &&
                DataType.isNumberType(rhsType) ) {

            // return the bigger type
View Full Code Here

    }

    @Override
    public void visit(ModExpression binOp) throws FrontendException {
        LogicalExpression lhs = binOp.getLhs() ;
        LogicalExpression rhs = binOp.getRhs() ;

        byte lhsType = lhs.getType() ;
        byte rhsType = rhs.getType() ;
        boolean error = false;

        if (lhsType == DataType.INTEGER) {
            if (rhsType == DataType.INTEGER) {
                //do nothing
View Full Code Here

    private void visitBooleanBinary(BinaryExpression boolExp)
    throws FrontendException {
        // if lhs or rhs is null constant then cast it to boolean
        insertCastsForNullToBoolean(boolExp);
        LogicalExpression lhs = boolExp.getLhs();
        LogicalExpression rhs = boolExp.getRhs();

        byte lhsType = lhs.getType() ;
        byte rhsType = rhs.getType() ;

        if (  (lhsType != DataType.BOOLEAN||
                (rhsType != DataType.BOOLEAN)  ) {
            int errCode = 1038;
            String msg = "Operands of AND/OR can be boolean only" ;
View Full Code Here

        addCastsToCompareBinaryExp(binOp, true /*equality op*/);
    }

    private void addCastsToCompareBinaryExp(BinaryExpression binOp, boolean isEquality)
    throws FrontendException {
        LogicalExpression lhs = binOp.getLhs() ;
        LogicalExpression rhs = binOp.getRhs() ;

        byte lhsType = lhs.getType() ;
        byte rhsType = rhs.getType() ;
        if ( DataType.isNumberType(lhsType) &&
                DataType.isNumberType(rhsType) ) {
            // If not the same type, we cast them to the same
            byte biggerType = lhsType > rhsType ? lhsType:rhsType ;

View Full Code Here

        if (pred.getLhs() instanceof ConstantExpression) {
            leftIsConst = true;
            leftConst = ((ConstantExpression) (pred.getLhs())).getValue();
        } else {
            LogicalExpression lhs = pred.getLhs();
            if (lhs instanceof CastExpression)
                lhs = ((CastExpression) lhs).getExpression();
            // if (!(pred.getLhsOperand() instanceof ProjectExpression && ((ProjectExpression)
            // pred
            // .getLhsOperand()).getProjection().size() == 1))
View Full Code Here

    }

    void GenerateMatchingTupleHelper(Tuple t, NotExpression op, boolean invert)
            throws FrontendException, ExecException {
        LogicalExpression input = op.getExpression();
        GenerateMatchingTupleHelper(t, input, !invert);

    }
View Full Code Here

            LOForEach foreach = (LOForEach)plan.getSinks().get(0);
            LogicalExpressionPlan foreachPlan =
                ((LOGenerate)foreach.getInnerPlan().getSinks().get(0)).getOutputPlans().get(1);

            LogicalExpression exOp = (LogicalExpression) foreachPlan.getSinks().get(0);

            if(! (exOp instanceof ProjectExpression)) exOp = (LogicalExpression) foreachPlan.getSinks().get(1);

            CastExpression cast1 = (CastExpression)foreachPlan.getPredecessors(exOp).get(0);
            MapLookupExpression map = (MapLookupExpression)foreachPlan.getPredecessors(cast1).get(0);
View Full Code Here

        private void checkLastFilterCast(String query, String loadFuncStr) throws FrontendException {
            LogicalPlan plan = createAndProcessLPlan(query);
            LOFilter filter = (LOFilter)plan.getSinks().get(0);
            LogicalExpressionPlan filterPlan = filter.getFilterPlan();

            LogicalExpression exOp = (LogicalExpression)filterPlan.getSinks().get(0);

            if(! (exOp instanceof ProjectExpression)) exOp = (LogicalExpression) filterPlan.getSinks().get(1);

            CastExpression cast = (CastExpression)filterPlan.getPredecessors(exOp).get(0);
            checkCastLoadFunc(cast, loadFuncStr);
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.expression.LogicalExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.