Search in sources :

Example 1 with AnalyticExpression

use of net.sf.jsqlparser.expression.AnalyticExpression in project JSqlParser by JSQLParser.

the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithAllColumns.

@Test
public void shouldDeParseAnalyticExpressionWithAllColumns() {
    AnalyticExpression analyticExpression = new AnalyticExpression();
    analyticExpression.setName("name");
    analyticExpression.setAllColumns(true);
    expressionDeParser.visit(analyticExpression);
    assertEquals("name(*) OVER ()", buffer.toString());
}
Also used : AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) Test(org.junit.Test)

Example 2 with AnalyticExpression

use of net.sf.jsqlparser.expression.AnalyticExpression in project JSqlParser by JSQLParser.

the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithExpression.

@Test
public void shouldDeParseAnalyticExpressionWithExpression() {
    AnalyticExpression analyticExpression = new AnalyticExpression();
    Expression expression = mock(Expression.class);
    analyticExpression.setName("name");
    analyticExpression.setExpression(expression);
    will(appendToBuffer("expression")).given(expression).accept(expressionDeParser);
    expressionDeParser.visit(analyticExpression);
    assertEquals("name(expression) OVER ()", buffer.toString());
}
Also used : Expression(net.sf.jsqlparser.expression.Expression) KeepExpression(net.sf.jsqlparser.expression.KeepExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) Test(org.junit.Test)

Example 3 with AnalyticExpression

use of net.sf.jsqlparser.expression.AnalyticExpression in project JSqlParser by JSQLParser.

the class ExpressionDeParserTest method shouldDeParseComplexAnalyticExpressionWithKeep.

@Test
public void shouldDeParseComplexAnalyticExpressionWithKeep() {
    AnalyticExpression analyticExpression = new AnalyticExpression();
    KeepExpression keep = mock(KeepExpression.class);
    analyticExpression.setName("name");
    analyticExpression.setKeep(keep);
    will(appendToBuffer("keep")).given(keep).accept(expressionDeParser);
    expressionDeParser.visit(analyticExpression);
    assertEquals("name() keep OVER ()", buffer.toString());
}
Also used : KeepExpression(net.sf.jsqlparser.expression.KeepExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) Test(org.junit.Test)

Example 4 with AnalyticExpression

use of net.sf.jsqlparser.expression.AnalyticExpression in project JSqlParser by JSQLParser.

the class ExpressionDeParserTest method shouldDeParseAnalyticExpressionWithOffset.

@Test
public void shouldDeParseAnalyticExpressionWithOffset() {
    AnalyticExpression analyticExpression = new AnalyticExpression();
    Expression expression = mock(Expression.class);
    Expression offset = mock(Expression.class);
    analyticExpression.setName("name");
    analyticExpression.setExpression(expression);
    analyticExpression.setOffset(offset);
    will(appendToBuffer("expression")).given(expression).accept(expressionDeParser);
    will(appendToBuffer("offset")).given(offset).accept(expressionDeParser);
    expressionDeParser.visit(analyticExpression);
    assertEquals("name(expression, offset) OVER ()", buffer.toString());
}
Also used : Expression(net.sf.jsqlparser.expression.Expression) KeepExpression(net.sf.jsqlparser.expression.KeepExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) Test(org.junit.Test)

Example 5 with AnalyticExpression

use of net.sf.jsqlparser.expression.AnalyticExpression in project JSqlParser by JSQLParser.

the class ExpressionDeParserTest method shouldDeParseComplexAnalyticExpressionWithPartitionExpressionList.

@Test
public void shouldDeParseComplexAnalyticExpressionWithPartitionExpressionList() {
    AnalyticExpression analyticExpression = new AnalyticExpression();
    ExpressionList partitionExpressionList = new ExpressionList();
    List<Expression> partitionExpressions = new ArrayList<Expression>();
    Expression partitionExpression1 = mock(Expression.class);
    Expression partitionExpression2 = mock(Expression.class);
    analyticExpression.setName("name");
    analyticExpression.setPartitionExpressionList(partitionExpressionList);
    partitionExpressionList.setExpressions(partitionExpressions);
    partitionExpressions.add(partitionExpression1);
    partitionExpressions.add(partitionExpression2);
    will(appendToBuffer("partition expression 1")).given(partitionExpression1).accept(expressionDeParser);
    will(appendToBuffer("partition expression 2")).given(partitionExpression2).accept(expressionDeParser);
    expressionDeParser.visit(analyticExpression);
    assertEquals("name() OVER (PARTITION BY partition expression 1, partition expression 2 )", buffer.toString());
}
Also used : Expression(net.sf.jsqlparser.expression.Expression) KeepExpression(net.sf.jsqlparser.expression.KeepExpression) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) ArrayList(java.util.ArrayList) AnalyticExpression(net.sf.jsqlparser.expression.AnalyticExpression) ExpressionList(net.sf.jsqlparser.expression.operators.relational.ExpressionList) Test(org.junit.Test)

Aggregations

AnalyticExpression (net.sf.jsqlparser.expression.AnalyticExpression)10 Test (org.junit.Test)9 KeepExpression (net.sf.jsqlparser.expression.KeepExpression)6 Expression (net.sf.jsqlparser.expression.Expression)5 ArrayList (java.util.ArrayList)3 OrderByElement (net.sf.jsqlparser.statement.select.OrderByElement)3 WindowElement (net.sf.jsqlparser.expression.WindowElement)2 ExpressionList (net.sf.jsqlparser.expression.operators.relational.ExpressionList)2 AllComparisonExpression (net.sf.jsqlparser.expression.AllComparisonExpression)1 AnyComparisonExpression (net.sf.jsqlparser.expression.AnyComparisonExpression)1 BinaryExpression (net.sf.jsqlparser.expression.BinaryExpression)1 CaseExpression (net.sf.jsqlparser.expression.CaseExpression)1 CastExpression (net.sf.jsqlparser.expression.CastExpression)1 DateTimeLiteralExpression (net.sf.jsqlparser.expression.DateTimeLiteralExpression)1 ExtractExpression (net.sf.jsqlparser.expression.ExtractExpression)1 IntervalExpression (net.sf.jsqlparser.expression.IntervalExpression)1 JsonExpression (net.sf.jsqlparser.expression.JsonExpression)1 NotExpression (net.sf.jsqlparser.expression.NotExpression)1 OracleHierarchicalExpression (net.sf.jsqlparser.expression.OracleHierarchicalExpression)1 OracleHint (net.sf.jsqlparser.expression.OracleHint)1