Package org.apache.hadoop.hbase.hbql.statement.select

Examples of org.apache.hadoop.hbase.hbql.statement.select.SelectExpressionContext


        assertTypeAndValue("FLOAT('1.0') * IF (TRUE) THEN SHORT('4') + LONG('5') ELSE 10 END", Float.class, (float)9.0);
        assertTypeAndValue("FLOAT('1.0') * IF (FALSE) THEN SHORT('4') + LONG('5') ELSE Integer('10') END", Float.class, (float)10.0);

        assertTypeAndValue("5.0+ FLOAT('4.0') + LONG('5')", Double.class, 14.0);

        SelectExpressionContext elem = parseSelectElement(":a + :b");

        elem.setParameter("a", (short)2);
        elem.setParameter("b", (short)4);
        assertTypeAndValue(elem, Short.class, (short)6);

        elem.setParameter("a", (short)2);
        elem.setParameter("b", (int)4);
        assertTypeAndValue(elem, Integer.class, (int)6);

        elem.setParameter("a", (int)2);
        elem.setParameter("b", (int)4);
        assertTypeAndValue(elem, Integer.class, (int)6);

        elem.setParameter("a", (long)2);
        elem.setParameter("b", (long)4);
        assertTypeAndValue(elem, Long.class, (long)6);

        elem.setParameter("a", (long)2);
        elem.setParameter("b", (float)4);
        assertTypeAndValue(elem, Float.class, (float)6);

        elem.setParameter("a", (float)2.0);
        elem.setParameter("b", (float)4.0);
        assertTypeAndValue(elem, Float.class, (float)6.0);

        elem.setParameter("a", (double)2.0);
        elem.setParameter("b", (double)4.0);
        assertTypeAndValue(elem, Double.class, (double)6.0);

        elem.setParameter("a", "aa");
        elem.setParameter("b", "bb");
        assertTypeAndValue(elem, String.class, "aabb");
    }
View Full Code Here


                           + " expecting type " + clazz.getSimpleName());
        assertTrue(obj.getClass().equals(clazz) && obj.equals(val));
    }

    public static void assertTypeAndValue(final String str, final Class clazz, final Object val) throws HBqlException {
        SelectExpressionContext expr = parseSelectElement(str);
        assertTypeAndValue(expr, clazz, val);
    }
View Full Code Here

    public List<Class<? extends GenericValue>> getValuesTypeList() throws HBqlException {
        final List<Class<? extends GenericValue>> typeList = Lists.newArrayList();
        for (final SelectElement element : this.getSelectStatement().getSelectElementList()) {
            if (element instanceof SelectExpressionContext) {
                final SelectExpressionContext expr = (SelectExpressionContext)element;
                final Class<? extends GenericValue> type = expr.getExpressionType();
                typeList.add(type);
            }
        }
        return typeList;
    }
View Full Code Here

    }

    public static SelectExpressionContext parseSelectElement(final String sql) throws HBqlException {
        try {
            final HBqlParser parser = ParserUtil.newHBqlParser(sql);
            final SelectExpressionContext elem = (SelectExpressionContext)parser.selectElem();
            elem.setMappingContext(null);
            return elem;
        }
        catch (RecognitionException e) {
            e.printStackTrace();
            throw new ParseException(e, sql);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.hbql.statement.select.SelectExpressionContext

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.