Examples of SearchedCaseExpression


Examples of com.facebook.presto.sql.tree.SearchedCaseExpression

        return new ComparisonExpression(ComparisonExpression.Type.EQUAL, left, right);
    }

    public static Expression caseWhen(Expression operand, Expression result)
    {
        return new SearchedCaseExpression(ImmutableList.of(new WhenClause(operand, result)), null);
    }
View Full Code Here

Examples of com.facebook.presto.sql.tree.SearchedCaseExpression

            Expression falseValue = null;
            if (node.getFalseValue().isPresent()) {
                falseValue = treeRewriter.rewrite(node.getFalseValue().get(), context);
            }

            return new SearchedCaseExpression(ImmutableList.of(new WhenClause(condition, trueValue)), falseValue);
        }
View Full Code Here

Examples of com.facebook.presto.sql.tree.SearchedCaseExpression

        return new ComparisonExpression(ComparisonExpression.Type.EQUAL, left, right);
    }

    public static Expression caseWhen(Expression operand, Expression result)
    {
        return new SearchedCaseExpression(ImmutableList.of(new WhenClause(operand, result)), null);
    }
View Full Code Here

Examples of com.facebook.presto.sql.tree.SearchedCaseExpression

            Expression falseValue = null;
            if (node.getFalseValue().isPresent()) {
                falseValue = treeRewriter.rewrite(node.getFalseValue().get(), context);
            }

            return new SearchedCaseExpression(ImmutableList.of(new WhenClause(condition, trueValue)), falseValue);
        }
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

          } else {
            if (agg.getAggregateFunction() == Type.COUNT) {
              if (agg.getExpression() == null) {
              projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", new Constant(1))); //$NON-NLS-1$
              } else {
                SearchedCaseExpression count = new SearchedCaseExpression(Arrays.asList(new IsNullCriteria(agg.getExpression())), Arrays.asList(new Constant(Integer.valueOf(0))));
                count.setElseExpression(new Constant(Integer.valueOf(1)));
                count.setType(DataTypeManager.DefaultDataClasses.INTEGER);
              projectedViewSymbols.add(new ExpressionSymbol("stagedAgg", count)); //$NON-NLS-1$
              }
            } else { //min, max, sum
              Expression ex = agg.getExpression();
              ex = ResolverUtil.convertExpression(ex, DataTypeManager.getDataTypeName(agg.getType()), metadata);
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

                }
                Expression n = new Constant(0);
                if (aggFunction == Type.STDDEV_SAMP || aggFunction == Type.VAR_SAMP) {
                  n = new Constant(1);
                }
                result = new SearchedCaseExpression(Arrays.asList(new CompareCriteria(sumCountAgg, CompareCriteria.GT, n)), Arrays.asList(result));
                ResolverVisitor.resolveLanguageObject(result, metadata);

                newExpression = result;
                nestedAggregates.add(countAgg);
                nestedAggregates.add(sumAgg);
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

        if (expr2 == null) {
            return expr1;
        }
       
        Criteria crit = new CompareCriteria(expr1, CompareCriteria.LT, expr2);
        SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new Object[] {crit}), Arrays.asList(new Object[] {expr1}));
        sce.setElseExpression(expr2);
        sce.setType(expr1.getType());
        return evaluateIfPossible(sce);
    }
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

        }
        return list;
    }
   
    public static SearchedCaseExpression helpExample() {
        SearchedCaseExpression caseExpr = new SearchedCaseExpression(getWhenCriteria(3), TestCaseExpression.getThenExpressions(3));
        caseExpr.setElseExpression(new Constant(new Integer(9999)));
        return caseExpr;
    }
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

        return TstLanguageBridgeFactory.factory.translate(helpExample());
    }

    public void testGetElseExpression() throws Exception {
        assertNotNull(example().getElseExpression());
        SearchedCaseExpression expr = helpExample();
        expr.setElseExpression(null);
        assertNull(TstLanguageBridgeFactory.factory.translate(expr).getElseExpression());
    }
View Full Code Here

Examples of org.teiid.query.sql.symbol.SearchedCaseExpression

        expr.setExpression(new Constant("d")); //$NON-NLS-1$
        helpTestEval(expr, null, null, null, null, new Integer(9999));
    }
   
    @Test public void testSearchedCaseExpression1() {
        SearchedCaseExpression expr = TestSearchedCaseExpression.example(3);
        helpTestEval(expr,
                     new SingleElementSymbol[] {new ElementSymbol("x")}, //$NON-NLS-1$
                     new Object[] {new Integer(0)},
                     null,
                     null,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.