Package org.apache.hadoop.hbase.hbql.impl

Examples of org.apache.hadoop.hbase.hbql.impl.InvalidTypeException


                continue;
            }

            if (type2.equals(NullLiteral.class)) {
                if (!TypeSupport.allowsNullValues(type1))
                    throw new InvalidTypeException("Argument " + i
                                                   + " type " + type1.getSimpleName()
                                                   + " cannot be assigned a NULL value"
                                                   + " in " + this.asString());
                continue;
            }

            if (!TypeSupport.isParentClass(type1, type2))
                throw new InvalidTypeException("Type mismatch with argument " + i
                                               + " expecting " + type1.getSimpleName()
                                               + " but found " + type2.getSimpleName()
                                               + " in " + this.asString());
        }
    }
View Full Code Here


        switch (this.getFunctionType()) {

            case DEFINEDINROW: {
                if (!(this.getExprArg(0) instanceof DelegateColumn))
                    throw new InvalidTypeException("Argument should be a column reference in: " + this.asString());
            }
        }

        return BooleanValue.class;
    }
View Full Code Here

    public Class<? extends GenericValue> validateTypes(final GenericValue parentExpr,
                                                       final boolean allowCollections) throws HBqlException {

        int i = 0;
        if (this.getGenericValueList().size() != this.getTypeSignature().getArgCount())
            throw new InvalidTypeException("Incorrect number of arguments in function " + this.getFunctionType().name()
                                           + " in " + this.asString());

        for (final Class<? extends GenericValue> clazz : this.getTypeSignature().getArgTypeList()) {
            final Class<? extends GenericValue> type = this.getExprArg(i).validateTypes(this, false);
            try {
                this.validateParentClass(clazz, type);
            }
            catch (InvalidTypeException e) {
                // Catch the exception and improve message
                throw new InvalidTypeException("Invalid type " + type.getSimpleName() + " for arg " + i + " in function "
                                               + this.getFunctionName() + " in "
                                               + this.asString() + ".  Expecting type " + clazz.getSimpleName() + ".");
            }
            i++;
        }
View Full Code Here

        else if (TypeSupport.isParentClass(BooleanValue.class, type1, type2))
            this.setTypedExpr(new BooleanIfThen(this.getExprArg(0), this.getExprArg(1), this.getExprArg(2)));
        else if (TypeSupport.isParentClass(ByteValue.class, type1, type2))
            this.setTypedExpr(new ByteIfThen(this.getExprArg(0), this.getExprArg(1), this.getExprArg(2)));
        else
            throw new InvalidTypeException(this.getInvalidTypeMsg(type1, type2));

        return this.getTypedExpr().validateTypes(parentExpr, false);
    }
View Full Code Here

    public void validate() throws HBqlException {

        for (final SelectElement element : this.getSelectStatement().getSelectElementList()) {
            if (element.isAFamilySelect())
                throw new InvalidTypeException("Family select items are not valid in INSERT statement");
        }

        this.getSelectStatement().validate(this.getInsertStatement().getConnection());
    }
View Full Code Here

        else if (TypeSupport.isParentClass(BooleanValue.class, type0, type1))
            this.typedExpr = new BooleanCompare(this.getExprArg(0), this.getOperator(), this.getExprArg(1));
        else if (TypeSupport.isParentClass(ByteValue.class, type0, type1))
            this.typedExpr = new ByteCompare(this.getExprArg(0), this.getOperator(), this.getExprArg(1));
        else
            throw new InvalidTypeException(this.getInvalidTypeMsg(type0, type1));

        return this.getTypedExpr().validateTypes(parentExpr, false);
    }
View Full Code Here

    public Class<? extends GenericValue> validateTypes(final GenericValue parentExpr,
                                                       final boolean allowCollections) throws HBqlException {

        if (this.getTypedExpr() == null && this.getTypedExprList() == null)
            throw new InvalidTypeException("Parameter \"" + this.getParamName() + "\" not assigned a value");

        if (this.isScalarValueSet()) {
            return this.getTypedExpr().getClass();
        }
        else {
            // Make sure a list is legal in this expr
            if (!allowCollections) {
                final String context = parentExpr == null ? "" : " in the context " + parentExpr.asString();
                throw new InvalidTypeException("Parameter " + this.getParamName()
                                               + " is assigned a collection which is not allowed" + context);
            }

            // if it is a list, then ensure that all the types in list are valid and consistent
            if (this.getTypedExprList().size() == 0)
                throw new InvalidTypeException("Parameter " + this.getParamName() + " is assigned a collection with no values");

            // Look at the type of the first item and then make sure the rest match that one
            final GenericValue firstval = this.getTypedExprList().get(0);
            final Class<? extends GenericValue> clazzToMatch = TypeSupport.getGenericExprType(firstval);

            for (final GenericValue val : this.getTypedExprList()) {

                final Class<? extends GenericValue> clazz = TypeSupport.getGenericExprType(val);

                if (clazz == null)
                    throw new InvalidTypeException("Parameter " + this.getParamName()
                                                   + " assigned a collection value with invalid type "
                                                   + firstval.getClass().getSimpleName());

                if (!clazz.equals(clazzToMatch))
                    throw new InvalidTypeException("Parameter " + this.getParamName()
                                                   + " assigned a collection value with type "
                                                   + firstval.getClass().getSimpleName()
                                                   + " which is inconsistent with the type of the first element");
            }
View Full Code Here

            return new DateLiteral((Date)val);

        if (val instanceof Object)
            return new ObjectLiteral(val);

        throw new InvalidTypeException("Parameter " + this.getParamName()
                                       + " assigned an unsupported type " + val.getClass().getSimpleName());
    }
View Full Code Here

        else if (TypeSupport.isParentClass(DateValue.class, valueType))
            this.setTypedExpr(new DateCaseWhen(this.getExprArg(0), this.getExprArg(1)));
        else if (TypeSupport.isParentClass(BooleanValue.class, valueType))
            this.setTypedExpr(new BooleanCaseWhen(this.getExprArg(0), this.getExprArg(1)));
        else
            throw new InvalidTypeException(this.getInvalidTypeMsg(valueType));

        return this.getTypedExpr().validateTypes(parentExpr, false);
    }
View Full Code Here

        else if (TypeSupport.isParentClass(DateValue.class, type0))
            this.setTypedExpr(new DateCaseElse(this.getExprArg(0)));
        else if (TypeSupport.isParentClass(BooleanValue.class, type0))
            this.setTypedExpr(new BooleanCaseElse(this.getExprArg(0)));
        else
            throw new InvalidTypeException(this.getInvalidTypeMsg(type0));

        return this.getTypedExpr().validateTypes(parentExpr, false);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.hbql.impl.InvalidTypeException

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.