Package adipe.translate.sql

Examples of adipe.translate.sql.Expression


        }
    }

    private Expression visitNumericValueExpression(NumericValueExpressionContext numericValueExpression,
            String columnAlias) throws TypeCheckException {
        Expression left = null;
        if (numericValueExpression.numericValueExpression() != null) {
            left = visitNumericValueExpression(numericValueExpression.numericValueExpression(), null);
        }
        Expression right = visitTerm(numericValueExpression.term(), columnAlias); // TODO should the alias be propagated?

        if (left == null) {
            return right;
        }
View Full Code Here


        }
    }

    private Expression visitTerm(TermContext term, String columnAlias) throws TypeCheckException
    {
        Expression left = null;

        if (term.term() != null) {
            left = visitTerm(term.term(), null);
        }
        Expression right = visitFactor(term.factor(), columnAlias); // TODO should the alias be propagated?
        if (left == null) {
            return right;
        }

        if (term.ASTERISK() != null) {
View Full Code Here

        }
    }

    private Expression visitFactor(FactorContext factor, String columnAlias) throws TypeCheckException
    {
        Expression expr = visitNumericPrimary(factor.numericPrimary(), columnAlias);
        if (factor.sign() == null || factor.sign().PLUS() != null) {
            return expr;
        }
        checkNotNull(factor.sign().MINUS());
        return Expressions.negate(expr);
View Full Code Here

        return visitCharacterValueExpression(stringValueExpression.characterValueExpression());
    }

    private Expression visitCharacterValueExpression(
            CharacterValueExpressionContext characterValueExpression) throws TypeCheckException {
        Expression left = null;
        if (characterValueExpression.characterValueExpression() != null) {
            left = visitCharacterValueExpression(characterValueExpression.characterValueExpression());
        }
        Expression right = visitCharacterFactor(characterValueExpression.characterFactor());
        if (left == null) {
            return right;
        }
        return Expressions.concatenate(left, right);
    }
View Full Code Here

        } else if (valueExpressionPrimary.setFunctionSpecification() != null) {
            return visitSetFunctionSpecification(valueExpressionPrimary.setFunctionSpecification(), columnAlias);
        } else if (valueExpressionPrimary.unsignedValueSpecification() != null) {
            return visitUnsignedValueSpecification(valueExpressionPrimary.unsignedValueSpecification());
        } else if (valueExpressionPrimary.LEFT_PAREN() != null) {
            Expression expr = visitValueExpression(valueExpressionPrimary.valueExpression());
            return Expressions.parens(expr);
        } else if (valueExpressionPrimary.externalCodeLiteral() != null) {
            // TODO infer type?
            return Expressions.ofFunction(ExternalCodeLiteralParser.parse(ex, valueExpressionPrimary.getText()));
        } else if (valueExpressionPrimary.castSpecification() != null) {
View Full Code Here

     * @throws TypeCheckException
     * @side  none
     */
    private Aggregated visitGeneralSetFunction(GeneralSetFunctionContext ctx, String columnAlias)
                        throws WrappedException, TypeCheckException {
        Expression inner = valueExpressionAsNamedColumn(ctx.valueExpression(), columnAlias);
        checkState(! inner.isAggregated());

        SetFunctionTypeContext setFunctionType = ctx.setFunctionType();
        NamedColumn innerNc = inner.conjure();
        if (inner.codeRefersToConjuredColumn()) {
            raBuilder.conjureColumnFrom(inner);
        }
        Aggregated aggr;

        boolean isDistinct = ctx.setQuantifier() != null && ctx.setQuantifier().DISTINCT() != null;
View Full Code Here

     * @throw WrappedException when an ambiguous column name is found
     * @throw WrappedException when no column of the referenced name is found
     * TODO update
     */
    private Expression visitSelectSublist(RaTermBuilder raBuilder, SelectSublistContext ctx) throws WrappedException, TypeCheckException {
        Expression ret = null;

        if (ctx.derivedColumn() == null) {
            checkNotNull(ctx.derivedColumn());
            //TODO
            //zawodzi dla "SELECT p.* FROM p"
View Full Code Here

            throw new RuntimeException("not implemented"); //TODO
        }
    }

    private Proposition visitNullPredicate(NullPredicateContext nullPredicate) throws WrappedException, TypeCheckException, RuntimeException {
        final Expression operand = visitRowValueConstructor(nullPredicate.rowValueConstructor());
        final boolean isNegated = nullPredicate.NOT() != null;
//        final String predicateCode;
//        if (isNegated) {
//            // TODO is this a correct check for IS NOT NULL?
////            predicateCode = "IFERROR(ERROR.TYPE(%s)<>ERROR.TYPE(#REF!),TRUE)";
//            predicateCode = Terms.isNotNoValueNull(value)
//        } else {
//            // TODO extract magic constant to {@link Terms}
//            // TODO also extract occurrences in {@link NullTest}
////            predicateCode = "IFERROR(ERROR.TYPE(%s)=ERROR.TYPE(#REF!),FALSE)";
//        }
        return c(new PropositionalLogic.Elementary.Coded() {

            @Override
            public String code(ColumnIndexes columnIndexes) {
//                return String.format(predicateCode, operand.code(columnIndexes));
                if (isNegated) {
                    return Terms.isNotNoValueNull(operand.code(columnIndexes));
                } else {
                    return Terms.isNoValueNull(operand.code(columnIndexes));
                }
            }

        });
    }
View Full Code Here

        });
    }

    private Proposition visitComparisonPredicate(final ComparisonPredicateContext ctx) throws WrappedException, TypeCheckException, RuntimeException {
        final Expression left  = visitRowValueConstructor(ctx.rowValueConstructor(0));
        final Expression right = visitRowValueConstructor(ctx.rowValueConstructor(1));
        // TODO refactor the below
        return c(new PropositionalLogic.Elementary.Coded() {
            @Override
            public String code(ColumnIndexes columnIndexes) {
                return String.format("%s%s%s", left.code(columnIndexes), ctx.compOp().getText(), right.code(columnIndexes));
            }
        });
    }
View Full Code Here

TOP

Related Classes of adipe.translate.sql.Expression

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.