Search in sources :

Example 16 with Limit

use of io.shardingjdbc.core.parsing.parser.context.limit.Limit in project sharding-jdbc by shardingjdbc.

the class DQLMergeEngineTest method assertBuildOrderByStreamMergedResultWithMySQLLimit.

@Test
public void assertBuildOrderByStreamMergedResultWithMySQLLimit() throws SQLException {
    selectStatement.setLimit(new Limit(DatabaseType.MySQL));
    selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
    assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
}
Also used : OrderItem(io.shardingjdbc.core.parsing.parser.context.OrderItem) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) MergedResult(io.shardingjdbc.core.merger.MergedResult) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) IteratorStreamMergedResult(io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) Test(org.junit.Test)

Example 17 with Limit

use of io.shardingjdbc.core.parsing.parser.context.limit.Limit in project sharding-jdbc by shardingjdbc.

the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithSQLServerLimit.

@Test
public void assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithSQLServerLimit() throws SQLException {
    selectStatement.setLimit(new Limit(DatabaseType.SQLServer));
    selectStatement.getItems().add(new AggregationSelectItem(AggregationType.COUNT, "(*)", Optional.<String>absent()));
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
    assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
Also used : AggregationSelectItem(io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) MergedResult(io.shardingjdbc.core.merger.MergedResult) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) IteratorStreamMergedResult(io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) Test(org.junit.Test)

Example 18 with Limit

use of io.shardingjdbc.core.parsing.parser.context.limit.Limit in project sharding-jdbc by shardingjdbc.

the class DQLMergeEngineTest method assertBuildGroupByStreamMergedResultWithSQLServerLimit.

@Test
public void assertBuildGroupByStreamMergedResultWithSQLServerLimit() throws SQLException {
    selectStatement.setLimit(new Limit(DatabaseType.SQLServer));
    selectStatement.getGroupByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
    selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
    assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
}
Also used : TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) OrderItem(io.shardingjdbc.core.parsing.parser.context.OrderItem) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) MergedResult(io.shardingjdbc.core.merger.MergedResult) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) IteratorStreamMergedResult(io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) Test(org.junit.Test)

Example 19 with Limit

use of io.shardingjdbc.core.parsing.parser.context.limit.Limit in project sharding-jdbc by shardingjdbc.

the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithMySQLLimit.

@Test
public void assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithMySQLLimit() throws SQLException {
    selectStatement.setLimit(new Limit(DatabaseType.MySQL));
    selectStatement.getItems().add(new AggregationSelectItem(AggregationType.COUNT, "(*)", Optional.<String>absent()));
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
    assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
Also used : AggregationSelectItem(io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) MergedResult(io.shardingjdbc.core.merger.MergedResult) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) IteratorStreamMergedResult(io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) Test(org.junit.Test)

Example 20 with Limit

use of io.shardingjdbc.core.parsing.parser.context.limit.Limit in project sharding-jdbc by shardingjdbc.

the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithOracleLimit.

@Test
public void assertBuildGroupByMemoryMergedResultWithAggregationOnlyWithOracleLimit() throws SQLException {
    selectStatement.setLimit(new Limit(DatabaseType.Oracle));
    selectStatement.getItems().add(new AggregationSelectItem(AggregationType.COUNT, "(*)", Optional.<String>absent()));
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertThat(actual, instanceOf(RowNumberDecoratorMergedResult.class));
    assertThat(((RowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
Also used : AggregationSelectItem(io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) GroupByStreamMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult) MergedResult(io.shardingjdbc.core.merger.MergedResult) LimitDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) TopAndRowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult) RowNumberDecoratorMergedResult(io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult) IteratorStreamMergedResult(io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult) OrderByStreamMergedResult(io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult) GroupByMemoryMergedResult(io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) Test(org.junit.Test)

Aggregations

Limit (io.shardingjdbc.core.parsing.parser.context.limit.Limit)46 Test (org.junit.Test)36 MergedResult (io.shardingjdbc.core.merger.MergedResult)27 LimitValue (io.shardingjdbc.core.parsing.parser.context.limit.LimitValue)27 GroupByMemoryMergedResult (io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult)15 GroupByStreamMergedResult (io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult)15 IteratorStreamMergedResult (io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult)15 OrderByStreamMergedResult (io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult)15 LimitDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult)15 RowNumberDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult)15 TopAndRowNumberDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult)15 RowCountToken (io.shardingjdbc.core.parsing.parser.token.RowCountToken)14 DQLMergeEngine (io.shardingjdbc.core.merger.dql.DQLMergeEngine)12 OrderItem (io.shardingjdbc.core.parsing.parser.context.OrderItem)12 OffsetToken (io.shardingjdbc.core.parsing.parser.token.OffsetToken)12 TableToken (io.shardingjdbc.core.parsing.parser.token.TableToken)9 SQLParsingException (io.shardingjdbc.core.parsing.parser.exception.SQLParsingException)5 AggregationSelectItem (io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem)3 SQLExpression (io.shardingjdbc.core.parsing.parser.expression.SQLExpression)3 SQLNumberExpression (io.shardingjdbc.core.parsing.parser.expression.SQLNumberExpression)3