未验证 提交 5768dcc6 编写于 作者: L Liang Zhang 提交者: GitHub

Add actual columns for ShorthandProjection (#4634)

* add actual columns for ShorthandProjection

* remove ProjectionsContext.columnLabels

* Merge branch 'master' into dev

# Conflicts:
#	shardingsphere-sql-parser/shardingsphere-sql-parser-relation/src/main/java/org/apache/shardingsphere/sql/parser/relation/segment/select/projection/engine/ProjectionsContextEngine.java
上级 d1674e51
......@@ -48,8 +48,8 @@ public final class PreparedJudgementEngineTest {
InsertColumnsSegment insertColumnsSegment = new InsertColumnsSegment(0, 0,
Arrays.asList(new ColumnSegment(0, 0, new IdentifierValue("id")), new ColumnSegment(0, 0, new IdentifierValue("name")), new ColumnSegment(0, 0, new IdentifierValue("shadow"))));
insertStatement.setInsertColumns(insertColumnsSegment);
InsertStatementContext insertStatementContext = new InsertStatementContext(relationMetas, Arrays.<Object>asList(1, "Tom", 2, "Jerry", 3, true), insertStatement);
PreparedJudgementEngine preparedJudgementEngine = new PreparedJudgementEngine(shadowRule, insertStatementContext, Arrays.<Object>asList(1, "Tom", true));
InsertStatementContext insertStatementContext = new InsertStatementContext(relationMetas, Arrays.asList(1, "Tom", 2, "Jerry", 3, true), insertStatement);
PreparedJudgementEngine preparedJudgementEngine = new PreparedJudgementEngine(shadowRule, insertStatementContext, Arrays.asList(1, "Tom", true));
Assert.assertTrue("should be shadow", preparedJudgementEngine.isShadowSQL());
}
}
......@@ -95,7 +95,7 @@ public final class ShardingDQLResultMerger implements ResultMerger {
}
private void setGroupByForDistinctRow(final SelectStatementContext selectStatementContext) {
for (int index = 1; index <= selectStatementContext.getProjectionsContext().getColumnLabels().size(); index++) {
for (int index = 1; index <= selectStatementContext.getProjectionsContext().getActualProjectionCount(); index++) {
OrderByItem orderByItem = new OrderByItem(new IndexOrderByItemSegment(-1, -1, index, OrderDirection.ASC, OrderDirection.ASC));
orderByItem.setIndex(index);
selectStatementContext.getGroupByContext().getItems().add(orderByItem);
......
......@@ -21,12 +21,10 @@ import org.apache.shardingsphere.sharding.merge.dal.ShardingDALResultMerger;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.SQLStatementContext;
import org.apache.shardingsphere.sql.parser.relation.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.sql.parser.relation.statement.SQLStatementContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.InsertStatementContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
......@@ -53,8 +51,8 @@ public final class ShardingResultMergerEngineTest {
public void assertNewInstanceWithSelectStatement() {
ShardingSphereProperties properties = new ShardingSphereProperties(new Properties());
SQLStatementContext sqlStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
assertThat(new ShardingResultMergerEngine().newInstance(DatabaseTypes.getActualDatabaseType("MySQL"), null, properties, sqlStatementContext), instanceOf(ShardingDQLResultMerger.class));
}
......
......@@ -17,7 +17,6 @@
package org.apache.shardingsphere.sharding.merge.dql.groupby;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.core.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.core.constant.OrderDirection;
......@@ -25,12 +24,12 @@ import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.Grou
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.impl.AggregationProjection;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Test;
......@@ -76,17 +75,17 @@ public final class GroupByMemoryMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
MergedResult actual = resultMerger.merge(Arrays.asList(queryResult1, queryResult2, queryResult3), createSelectStatementContext(), null);
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(30)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(30)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(3));
assertThat((BigDecimal) actual.getValue(4, Object.class), is(new BigDecimal(3)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(30)));
assertThat(actual.getValue(3, Object.class), is(3));
assertThat(actual.getValue(4, Object.class), is(new BigDecimal(3)));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(30)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(2));
assertThat((BigDecimal) actual.getValue(4, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(3, Object.class), is(2));
assertThat(actual.getValue(4, Object.class), is(new BigDecimal(4)));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(40)));
assertFalse(actual.next());
}
......@@ -101,7 +100,7 @@ public final class GroupByMemoryMergedResultTest {
AggregationProjection derivedAggregationProjection2 = new AggregationProjection(AggregationType.SUM, "(num)", "AVG_DERIVED_SUM_0");
aggregationProjection2.setIndex(5);
aggregationProjection2.getDerivedAggregationProjections().add(derivedAggregationProjection2);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Arrays.<Projection>asList(aggregationProjection1, aggregationProjection2), Collections.<String>emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Arrays.asList(aggregationProjection1, aggregationProjection2));
return new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.singletonList(createOrderByItem(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC))), 0),
new OrderByContext(Collections.singletonList(createOrderByItem(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.DESC, OrderDirection.ASC))), false),
......
......@@ -18,18 +18,17 @@
package org.apache.shardingsphere.sharding.merge.dql.groupby;
import com.google.common.collect.Lists;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.impl.memory.MemoryQueryResultRow;
import org.apache.shardingsphere.sql.parser.core.constant.OrderDirection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.impl.memory.MemoryQueryResultRow;
import org.junit.Test;
import java.sql.ResultSet;
......@@ -58,7 +57,7 @@ public final class GroupByRowComparatorTest {
new OrderByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, OrderDirection.ASC))), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("3", "4"));
......@@ -74,7 +73,7 @@ public final class GroupByRowComparatorTest {
new OrderByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("3", "4"));
......@@ -90,7 +89,7 @@ public final class GroupByRowComparatorTest {
new OrderByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("1", "2"));
......@@ -102,8 +101,8 @@ public final class GroupByRowComparatorTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, OrderDirection.ASC))), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.ASC, OrderDirection.ASC))), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("3", "4"));
......@@ -115,8 +114,8 @@ public final class GroupByRowComparatorTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.DESC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("3", "4"));
......@@ -128,8 +127,8 @@ public final class GroupByRowComparatorTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC)),
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
createOrderByItem(new IndexOrderByItemSegment(0, 0, 2, OrderDirection.DESC, OrderDirection.ASC))), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatementContext, caseSensitives);
MemoryQueryResultRow o1 = new MemoryQueryResultRow(createQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(createQueryResult("1", "2"));
......
......@@ -17,7 +17,6 @@
package org.apache.shardingsphere.sharding.merge.dql.groupby;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.core.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.core.constant.OrderDirection;
......@@ -25,12 +24,12 @@ import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.Grou
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.impl.AggregationProjection;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Test;
......@@ -80,19 +79,19 @@ public final class GroupByStreamMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
MergedResult actual = resultMerger.merge(Arrays.asList(queryResult1, queryResult2, queryResult3), createSelectStatementContext(), null);
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(2));
assertThat((Date) actual.getCalendarValue(4, Date.class, Calendar.getInstance()), is(new Date(0L)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(3, Object.class), is(2));
assertThat(actual.getCalendarValue(4, Date.class, Calendar.getInstance()), is(new Date(0L)));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(30)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(30)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(3));
assertThat((Date) actual.getCalendarValue(4, Date.class, Calendar.getInstance()), is(new Date(0L)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(3)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(30)));
assertThat(actual.getValue(3, Object.class), is(3));
assertThat(actual.getCalendarValue(4, Date.class, Calendar.getInstance()), is(new Date(0L)));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(3)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(30)));
assertFalse(actual.next());
}
......@@ -122,29 +121,29 @@ public final class GroupByStreamMergedResultTest {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
MergedResult actual = resultMerger.merge(Arrays.asList(queryResult1, queryResult2, queryResult3), createSelectStatementContext(), null);
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(10)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(10)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(1));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(1)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(10)));
assertThat(actual.getValue(3, Object.class), is(1));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(1)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(10)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(2));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(3, Object.class), is(2));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(60)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(60)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(3));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(6)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(60)));
assertThat(actual.getValue(3, Object.class), is(3));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(6)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(60)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(4));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertThat(actual.getValue(3, Object.class), is(4));
assertThat(actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat(actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertFalse(actual.next());
}
......@@ -159,7 +158,7 @@ public final class GroupByStreamMergedResultTest {
AggregationProjection derivedAggregationProjection2 = new AggregationProjection(AggregationType.SUM, "(num)", "AVG_DERIVED_SUM_0");
aggregationProjection2.setIndex(6);
aggregationProjection2.getDerivedAggregationProjections().add(derivedAggregationProjection2);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Arrays.<Projection>asList(aggregationProjection1, aggregationProjection2), Collections.<String>emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Arrays.asList(aggregationProjection1, aggregationProjection2));
return new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.singletonList(new OrderByItem(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC))), 0),
new OrderByContext(Collections.singletonList(new OrderByItem(new IndexOrderByItemSegment(0, 0, 3, OrderDirection.ASC, OrderDirection.ASC))), false),
......
......@@ -17,16 +17,14 @@
package org.apache.shardingsphere.sharding.merge.dql.iterator;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Before;
......@@ -49,8 +47,8 @@ public final class IteratorStreamMergedResultTest {
@Before
public void setUp() {
selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
}
@Test
......
......@@ -17,18 +17,17 @@
package org.apache.shardingsphere.sharding.merge.dql.orderby;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.core.constant.OrderDirection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.order.item.IndexOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Before;
......@@ -53,9 +52,9 @@ public final class OrderByStreamMergedResultTest {
@Before
public void setUp() {
selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0),
new GroupByContext(Collections.emptyList(), 0),
new OrderByContext(Collections.singletonList(new OrderByItem(new IndexOrderByItemSegment(0, 0, 1, OrderDirection.ASC, OrderDirection.ASC))), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
}
@Test
......
......@@ -17,17 +17,15 @@
package org.apache.shardingsphere.sharding.merge.dql.pagination;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.pagination.limit.NumberLiteralLimitValueSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Test;
......@@ -47,8 +45,8 @@ public final class LimitDecoratorMergedResultTest {
public void assertNextForSkipAll() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralLimitValueSegment(0, 0, Integer.MAX_VALUE), null, Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertFalse(actual.next());
......@@ -58,8 +56,8 @@ public final class LimitDecoratorMergedResultTest {
public void assertNextWithoutRowCount() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralLimitValueSegment(0, 0, 2), null, Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
for (int i = 0; i < 6; i++) {
......@@ -72,8 +70,8 @@ public final class LimitDecoratorMergedResultTest {
public void assertNextWithRowCount() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("MySQL"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralLimitValueSegment(0, 0, 2), new NumberLiteralLimitValueSegment(0, 0, 2), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertTrue(actual.next());
......
......@@ -17,17 +17,15 @@
package org.apache.shardingsphere.sharding.merge.dql.pagination;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.pagination.rownum.NumberLiteralRowNumberValueSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Test;
......@@ -47,8 +45,8 @@ public final class RowNumberDecoratorMergedResultTest {
public void assertNextForSkipAll() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("Oracle"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, Integer.MAX_VALUE, true), null, Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertFalse(actual.next());
......@@ -58,8 +56,8 @@ public final class RowNumberDecoratorMergedResultTest {
public void assertNextWithoutOffsetWithoutRowCount() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("Oracle"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()), new PaginationContext(null, null, Collections.emptyList()));
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()), new PaginationContext(null, null, Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
for (int i = 0; i < 8; i++) {
assertTrue(actual.next());
......@@ -71,8 +69,8 @@ public final class RowNumberDecoratorMergedResultTest {
public void assertNextForRowCountBoundOpenedFalse() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("Oracle"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, 2, true), new NumberLiteralRowNumberValueSegment(0, 0, 4, false), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertTrue(actual.next());
......@@ -84,8 +82,8 @@ public final class RowNumberDecoratorMergedResultTest {
public void assertNextForRowCountBoundOpenedTrue() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("Oracle"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, 2, true), new NumberLiteralRowNumberValueSegment(0, 0, 4, true), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertTrue(actual.next());
......
......@@ -17,18 +17,16 @@
package org.apache.shardingsphere.sharding.merge.dql.pagination;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.pagination.limit.NumberLiteralLimitValueSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.pagination.rownum.NumberLiteralRowNumberValueSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import org.apache.shardingsphere.underlying.common.database.type.DatabaseTypes;
import org.apache.shardingsphere.underlying.executor.QueryResult;
import org.apache.shardingsphere.underlying.merge.result.MergedResult;
import org.junit.Test;
......@@ -47,8 +45,8 @@ public final class TopAndRowNumberDecoratorMergedResultTest {
@Test
public void assertNextForSkipAll() throws SQLException {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, Integer.MAX_VALUE, true), null, Collections.emptyList()));
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("SQLServer"));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
......@@ -59,8 +57,8 @@ public final class TopAndRowNumberDecoratorMergedResultTest {
public void assertNextWithoutOffsetWithRowCount() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("SQLServer"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(null, new NumberLiteralLimitValueSegment(0, 0, 5), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
for (int i = 0; i < 5; i++) {
......@@ -73,8 +71,8 @@ public final class TopAndRowNumberDecoratorMergedResultTest {
public void assertNextWithOffsetWithoutRowCount() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("SQLServer"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, 2, true), null, Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
for (int i = 0; i < 7; i++) {
......@@ -87,8 +85,8 @@ public final class TopAndRowNumberDecoratorMergedResultTest {
public void assertNextWithOffsetBoundOpenedFalse() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("SQLServer"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, 2, false), new NumberLiteralLimitValueSegment(0, 0, 4), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertTrue(actual.next());
......@@ -100,8 +98,8 @@ public final class TopAndRowNumberDecoratorMergedResultTest {
public void assertNextWithOffsetBoundOpenedTrue() throws SQLException {
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(DatabaseTypes.getActualDatabaseType("SQLServer"));
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(new NumberLiteralRowNumberValueSegment(0, 0, 2, true), new NumberLiteralLimitValueSegment(0, 0, 4), Collections.emptyList()));
MergedResult actual = resultMerger.merge(Arrays.asList(createQueryResult(), createQueryResult(), createQueryResult(), createQueryResult()), selectStatementContext, null);
assertTrue(actual.next());
......
......@@ -21,9 +21,7 @@ import org.apache.shardingsphere.core.rule.ShardingRule;
import org.apache.shardingsphere.sharding.route.fixture.AbstractRoutingEngineTest;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
......@@ -33,11 +31,11 @@ import org.apache.shardingsphere.underlying.route.context.RouteResult;
import org.apache.shardingsphere.underlying.route.context.RouteUnit;
import org.junit.Test;
import java.util.Collections;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
......@@ -49,8 +47,8 @@ public final class ShardingComplexRoutingEngineTest extends AbstractRoutingEngin
@Test
public void assertRoutingForBindingTables() {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(null, null, Collections.emptyList()));
ShardingComplexRoutingEngine complexRoutingEngine = new ShardingComplexRoutingEngine(Arrays.asList("t_order", "t_order_item"), selectStatementContext,
createShardingConditions("t_order"), new ShardingSphereProperties(new Properties()));
......@@ -67,8 +65,8 @@ public final class ShardingComplexRoutingEngineTest extends AbstractRoutingEngin
@Test
public void assertRoutingForShardingTableJoinBroadcastTable() {
SelectStatementContext selectStatementContext = new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(null, null, Collections.emptyList()));
ShardingComplexRoutingEngine complexRoutingEngine = new ShardingComplexRoutingEngine(Arrays.asList("t_order", "t_config"), selectStatementContext,
createShardingConditions("t_order"), new ShardingSphereProperties(new Properties()));
......@@ -84,7 +82,7 @@ public final class ShardingComplexRoutingEngineTest extends AbstractRoutingEngin
@Test(expected = ShardingSphereException.class)
public void assertRoutingForNonLogicTable() {
ShardingComplexRoutingEngine complexRoutingEngine = new ShardingComplexRoutingEngine(Collections.<String>emptyList(), null,
ShardingComplexRoutingEngine complexRoutingEngine = new ShardingComplexRoutingEngine(Collections.emptyList(), null,
createShardingConditions("t_order"), new ShardingSphereProperties(new Properties()));
complexRoutingEngine.route(mock(ShardingRule.class));
}
......
......@@ -19,14 +19,11 @@ package org.apache.shardingsphere.sharding.route.engine.type.standard;
import org.apache.shardingsphere.api.hint.HintManager;
import org.apache.shardingsphere.core.rule.ShardingRule;
import org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
import org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditions;
import org.apache.shardingsphere.sharding.route.fixture.AbstractRoutingEngineTest;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.sql.parser.relation.segment.select.pagination.PaginationContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.sql.parser.relation.segment.table.TablesContext;
import org.apache.shardingsphere.sql.parser.relation.statement.SQLStatementContext;
......@@ -71,7 +68,7 @@ public final class ShardingStandardRoutingEngineTest extends AbstractRoutingEngi
@Test
public void assertRouteByNonConditions() {
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_order", new ShardingConditions(Collections.<ShardingCondition>emptyList()));
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_order", new ShardingConditions(Collections.emptyList()));
RouteResult routeResult = standardRoutingEngine.route(createBasedShardingRule());
List<RouteUnit> tableUnitList = new ArrayList<>(routeResult.getRouteUnits());
assertThat(routeResult, instanceOf(RouteResult.class));
......@@ -109,7 +106,7 @@ public final class ShardingStandardRoutingEngineTest extends AbstractRoutingEngi
@Test
public void assertRouteByHint() {
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_test", new ShardingConditions(Collections.<ShardingCondition>emptyList()));
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_test", new ShardingConditions(Collections.emptyList()));
HintManager hintManager = HintManager.getInstance();
hintManager.addDatabaseShardingValue("t_hint_test", 1);
hintManager.addTableShardingValue("t_hint_test", 1);
......@@ -140,7 +137,7 @@ public final class ShardingStandardRoutingEngineTest extends AbstractRoutingEngi
@Test
public void assertRouteByMixedWithHintDatasourceOnly() {
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_ds_test", new ShardingConditions(Collections.<ShardingCondition>emptyList()));
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_ds_test", new ShardingConditions(Collections.emptyList()));
HintManager hintManager = HintManager.getInstance();
hintManager.addDatabaseShardingValue("t_hint_ds_test", 1);
RouteResult routeResult = standardRoutingEngine.route(createMixedShardingRule());
......@@ -174,7 +171,7 @@ public final class ShardingStandardRoutingEngineTest extends AbstractRoutingEngi
@Test
public void assertRouteByMixedWithHintTableOnly() {
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_table_test", new ShardingConditions(Collections.<ShardingCondition>emptyList()));
ShardingStandardRoutingEngine standardRoutingEngine = createShardingStandardRoutingEngine("t_hint_table_test", new ShardingConditions(Collections.emptyList()));
HintManager hintManager = HintManager.getInstance();
hintManager.addTableShardingValue("t_hint_table_test", 1);
RouteResult routeResult = standardRoutingEngine.route(createMixedShardingRule());
......@@ -193,8 +190,8 @@ public final class ShardingStandardRoutingEngineTest extends AbstractRoutingEngi
private ShardingStandardRoutingEngine createShardingStandardRoutingEngine(final String logicTableName, final ShardingConditions shardingConditions) {
return new ShardingStandardRoutingEngine(logicTableName, new SelectStatementContext(new SelectStatement(),
new GroupByContext(Collections.<OrderByItem>emptyList(), 0), new OrderByContext(Collections.<OrderByItem>emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.<Projection>emptyList(), Collections.<String>emptyList()),
new GroupByContext(Collections.emptyList(), 0), new OrderByContext(Collections.emptyList(), false),
new ProjectionsContext(0, 0, false, Collections.emptyList()),
new PaginationContext(null, null, Collections.emptyList())), shardingConditions, new ShardingSphereProperties(new Properties()));
}
}
......@@ -71,7 +71,7 @@ public final class OracleDCLVisitor extends OracleVisitor implements DCLVisitor
@SuppressWarnings("unchecked")
private Collection<SimpleTableSegment> getTableFromPrivilegeClause(final ObjectPrivilegeClauseContext ctx) {
return null == ctx.onObjectClause().tableName() ? Collections.<SimpleTableSegment>emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onObjectClause().tableName()));
return null == ctx.onObjectClause().tableName() ? Collections.emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onObjectClause().tableName()));
}
@Override
......
......@@ -72,7 +72,7 @@ public final class PostgreSQLDCLVisitor extends PostgreSQLVisitor implements DCL
@SuppressWarnings("unchecked")
private Collection<SimpleTableSegment> getTableFromPrivilegeClause(final PrivilegeClauseContext ctx) {
return null == ctx.onObjectClause().tableNames() ? Collections.<SimpleTableSegment>emptyList() : ((CollectionValue<SimpleTableSegment>) visit(ctx.onObjectClause().tableNames())).getValue();
return null == ctx.onObjectClause().tableNames() ? Collections.emptyList() : ((CollectionValue<SimpleTableSegment>) visit(ctx.onObjectClause().tableNames())).getValue();
}
@Override
......
......@@ -45,8 +45,6 @@ public final class ProjectionsContext {
private final Collection<Projection> projections;
private final List<String> columnLabels;
/**
* Judge is unqualified shorthand projection or not.
*
......@@ -123,4 +121,21 @@ public final class ProjectionsContext {
}
return result;
}
/**
* Get actual projection count.
*
* @return actual projection count
*/
public int getActualProjectionCount() {
int result = 0;
for (Projection each : projections) {
if (each instanceof ShorthandProjection) {
result += ((ShorthandProjection) each).getActualColumns().size();
} else {
result++;
}
}
return result;
}
}
......@@ -17,7 +17,9 @@
package org.apache.shardingsphere.sql.parser.relation.segment.select.projection.engine;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.core.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.relation.metadata.RelationMetas;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.DerivedColumn;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.impl.AggregationDistinctProjection;
......@@ -31,14 +33,22 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ColumnProjectio
import org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ExpressionProjectionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ProjectionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.item.ShorthandProjectionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Projection engine.
*/
@RequiredArgsConstructor
public final class ProjectionEngine {
private final RelationMetas relationMetas;
private int aggregationAverageDerivedColumnCount;
private int aggregationDistinctDerivedColumnCount;
......@@ -47,12 +57,13 @@ public final class ProjectionEngine {
* Create projection.
*
* @param sql SQL
* @param tableSegments table segments
* @param projectionSegment projection segment
* @return projection
*/
public Optional<Projection> createProjection(final String sql, final ProjectionSegment projectionSegment) {
public Optional<Projection> createProjection(final String sql, final Collection<SimpleTableSegment> tableSegments, final ProjectionSegment projectionSegment) {
if (projectionSegment instanceof ShorthandProjectionSegment) {
return Optional.of(createProjection((ShorthandProjectionSegment) projectionSegment));
return Optional.of(createProjection(tableSegments, (ShorthandProjectionSegment) projectionSegment));
}
if (projectionSegment instanceof ColumnProjectionSegment) {
return Optional.of(createProjection((ColumnProjectionSegment) projectionSegment));
......@@ -70,8 +81,10 @@ public final class ProjectionEngine {
return Optional.empty();
}
private ShorthandProjection createProjection(final ShorthandProjectionSegment projectionSegment) {
return new ShorthandProjection(projectionSegment.getOwner().map(owner -> owner.getIdentifier().getValue()).orElse(null));
private ShorthandProjection createProjection(final Collection<SimpleTableSegment> tableSegments, final ShorthandProjectionSegment projectionSegment) {
String owner = projectionSegment.getOwner().map(ownerSegment -> ownerSegment.getIdentifier().getValue()).orElse(null);
Collection<ColumnProjection> columns = getShorthandColumns(tableSegments, owner);
return new ShorthandProjection(owner, columns);
}
private ColumnProjection createProjection(final ColumnProjectionSegment projectionSegment) {
......@@ -104,6 +117,30 @@ public final class ProjectionEngine {
return result;
}
private Collection<ColumnProjection> getShorthandColumns(final Collection<SimpleTableSegment> tables, final String owner) {
return null == owner ? getUnqualifiedShorthandColumns(tables) : getQualifiedShorthandColumns(tables, owner);
}
private Collection<ColumnProjection> getQualifiedShorthandColumns(final Collection<SimpleTableSegment> tables, final String owner) {
for (SimpleTableSegment each : tables) {
String tableName = each.getTableName().getIdentifier().getValue();
if (owner.equalsIgnoreCase(each.getAlias().orElse(tableName))) {
return relationMetas.getAllColumnNames(tableName).stream().map(columnName -> new ColumnProjection(tableName, columnName, null)).collect(Collectors.toList());
}
}
return Collections.emptyList();
}
private Collection<ColumnProjection> getUnqualifiedShorthandColumns(final Collection<SimpleTableSegment> tables) {
Collection<ColumnProjection> result = new LinkedList<>();
for (SimpleTableSegment each : tables) {
String tableName = each.getTableName().getIdentifier().getValue();
result.addAll(relationMetas.getAllColumnNames(
each.getTableName().getIdentifier().getValue()).stream().map(columnName -> new ColumnProjection(tableName, columnName, null)).collect(Collectors.toList()));
}
return result;
}
private void appendAverageDistinctDerivedProjection(final AggregationDistinctProjection averageDistinctProjection) {
String innerExpression = averageDistinctProjection.getInnerExpression();
String distinctInnerExpression = averageDistinctProjection.getDistinctInnerExpression();
......
......@@ -18,7 +18,6 @@
package org.apache.shardingsphere.sql.parser.relation.segment.select.projection.engine;
import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.relation.metadata.RelationMetas;
import org.apache.shardingsphere.sql.parser.relation.segment.select.groupby.GroupByContext;
import org.apache.shardingsphere.sql.parser.relation.segment.select.orderby.OrderByContext;
......@@ -37,22 +36,23 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.order.item.TextOrder
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
/**
* Projections context engine.
*/
@RequiredArgsConstructor
public final class ProjectionsContextEngine {
private final RelationMetas relationMetas;
private final ProjectionEngine projectionEngine = new ProjectionEngine();
private final ProjectionEngine projectionEngine;
public ProjectionsContextEngine(final RelationMetas relationMetas) {
this.relationMetas = relationMetas;
projectionEngine = new ProjectionEngine(relationMetas);
}
/**
* Create projections context.
......@@ -65,52 +65,17 @@ public final class ProjectionsContextEngine {
*/
public ProjectionsContext createProjectionsContext(final String sql, final SelectStatement selectStatement, final GroupByContext groupByContext, final OrderByContext orderByContext) {
ProjectionsSegment projectionsSegment = selectStatement.getProjections();
Collection<Projection> projections = getProjections(sql, projectionsSegment);
ProjectionsContext result = new ProjectionsContext(
projectionsSegment.getStartIndex(), projectionsSegment.getStopIndex(), projectionsSegment.isDistinctRow(), projections, getColumnLabels(selectStatement.getTables(), projections));
Collection<Projection> projections = getProjections(sql, selectStatement.getTables(), projectionsSegment);
ProjectionsContext result = new ProjectionsContext(projectionsSegment.getStartIndex(), projectionsSegment.getStopIndex(), projectionsSegment.isDistinctRow(), projections);
result.getProjections().addAll(getDerivedGroupByColumns(projections, groupByContext, selectStatement));
result.getProjections().addAll(getDerivedOrderByColumns(projections, orderByContext, selectStatement));
return result;
}
private Collection<Projection> getProjections(final String sql, final ProjectionsSegment projectionsSegment) {
private Collection<Projection> getProjections(final String sql, final Collection<SimpleTableSegment> tableSegments, final ProjectionsSegment projectionsSegment) {
Collection<Projection> result = new LinkedList<>();
for (ProjectionSegment each : projectionsSegment.getProjections()) {
projectionEngine.createProjection(sql, each).ifPresent(result::add);
}
return result;
}
private List<String> getColumnLabels(final Collection<SimpleTableSegment> tables, final Collection<Projection> projections) {
List<String> result = new ArrayList<>(projections.size());
for (Projection each : projections) {
if (each instanceof ShorthandProjection) {
result.addAll(getShorthandColumnLabels(tables, (ShorthandProjection) each));
} else {
result.add(each.getColumnLabel());
}
}
return result;
}
private Collection<String> getShorthandColumnLabels(final Collection<SimpleTableSegment> tables, final ShorthandProjection shorthandProjection) {
return shorthandProjection.getOwner().isPresent()
? getQualifiedShorthandColumnLabels(tables, shorthandProjection.getOwner().get()) : getUnqualifiedShorthandColumnLabels(tables);
}
private Collection<String> getQualifiedShorthandColumnLabels(final Collection<SimpleTableSegment> tables, final String owner) {
for (SimpleTableSegment each : tables) {
if (owner.equalsIgnoreCase(each.getAlias().orElse(each.getTableName().getIdentifier().getValue()))) {
return relationMetas.getAllColumnNames(each.getTableName().getIdentifier().getValue());
}
}
return Collections.emptyList();
}
private Collection<String> getUnqualifiedShorthandColumnLabels(final Collection<SimpleTableSegment> tables) {
Collection<String> result = new LinkedList<>();
for (SimpleTableSegment each : tables) {
result.addAll(relationMetas.getAllColumnNames(each.getTableName().getIdentifier().getValue()));
projectionEngine.createProjection(sql, tableSegments, each).ifPresent(result::add);
}
return result;
}
......
......@@ -54,12 +54,12 @@ public class AggregationProjection implements Projection {
public final String getExpression() {
return SQLUtil.getExactlyValue(type.name() + innerExpression);
}
@Override
public final Optional<String> getAlias() {
return Optional.ofNullable(alias);
}
/**
* Get column label.
*
......
......@@ -33,23 +33,23 @@ import java.util.Optional;
@EqualsAndHashCode
@ToString
public final class ColumnProjection implements Projection {
private final String owner;
private final String name;
private final String alias;
@Override
public String getExpression() {
return null == owner ? name : owner + "." + name;
}
@Override
public String getColumnLabel() {
return getAlias().orElse(name);
}
@Override
public Optional<String> getAlias() {
return Optional.ofNullable(alias);
......
......@@ -33,16 +33,16 @@ import java.util.Optional;
@EqualsAndHashCode
@ToString
public final class DerivedProjection implements Projection {
private final String expression;
private final String alias;
@Override
public Optional<String> getAlias() {
return Optional.ofNullable(alias);
}
@Override
public String getColumnLabel() {
return getAlias().orElse(getExpression());
......
......@@ -33,16 +33,16 @@ import java.util.Optional;
@EqualsAndHashCode
@ToString
public final class ExpressionProjection implements Projection {
private final String expression;
private final String alias;
@Override
public Optional<String> getAlias() {
return Optional.ofNullable(alias);
}
@Override
public String getColumnLabel() {
return getAlias().orElse(getExpression());
......
......@@ -24,6 +24,7 @@ import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import java.util.Collection;
import java.util.Optional;
/**
......@@ -37,6 +38,8 @@ public final class ShorthandProjection implements Projection {
private final String owner;
private final Collection<ColumnProjection> actualColumns;
@Override
public String getExpression() {
return Strings.isNullOrEmpty(owner) ? "*" : owner + ".*";
......@@ -46,12 +49,12 @@ public final class ShorthandProjection implements Projection {
public Optional<String> getAlias() {
return Optional.empty();
}
@Override
public String getColumnLabel() {
return getAlias().orElse("*");
return "*";
}
/**
* Get owner.
*
......
......@@ -63,7 +63,7 @@ public final class PaginationContextEngineTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
selectStatement.setWhere(new WhereSegment(0, 10));
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList(), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList());
PaginationContext paginationContext = new PaginationContextEngine().createPaginationContext(selectStatement, projectionsContext, Collections.emptyList());
assertFalse(paginationContext.getOffsetSegment().isPresent());
assertFalse(paginationContext.getRowCountSegment().isPresent());
......@@ -73,7 +73,7 @@ public final class PaginationContextEngineTest {
public void assertCreatePaginationContextWhenResultIsPaginationContext() {
SelectStatement selectStatement = new SelectStatement();
selectStatement.setProjections(new ProjectionsSegment(0, 0));
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList(), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList());
assertThat(new PaginationContextEngine().createPaginationContext(selectStatement, projectionsContext, Collections.emptyList()), instanceOf(PaginationContext.class));
}
}
......@@ -50,7 +50,7 @@ public final class RowNumberPaginationContextEngineTest {
@Test
public void assertCreatePaginationContextWhenRowNumberAliasNotPresent() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList(), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.emptyList());
PaginationContext paginationContext = new RowNumberPaginationContextEngine().createPaginationContext(null, projectionsContext, Collections.emptyList());
assertFalse(paginationContext.getOffsetSegment().isPresent());
assertFalse(paginationContext.getRowCountSegment().isPresent());
......@@ -59,7 +59,7 @@ public final class RowNumberPaginationContextEngineTest {
@Test
public void assertCreatePaginationContextWhenRowNumberAliasIsPresentAndRowNumberPredicatesIsEmpty() {
Projection projectionWithRowNumberAlias = new ColumnProjection(null, ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias));
PaginationContext paginationContext = new RowNumberPaginationContextEngine().createPaginationContext(Collections.emptyList(), projectionsContext, Collections.emptyList());
assertFalse(paginationContext.getOffsetSegment().isPresent());
assertFalse(paginationContext.getRowCountSegment().isPresent());
......@@ -88,7 +88,7 @@ public final class RowNumberPaginationContextEngineTest {
@Test
public void assertCreatePaginationContextWhenRowNumberAliasIsPresentAndRowNumberPredicatesNotEmpty() {
Projection projectionWithRowNumberAlias = new ColumnProjection(null, ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias));
AndPredicate andPredicate = new AndPredicate();
PredicateSegment predicateSegment = new PredicateSegment(0, 0, new ColumnSegment(0, 10, new IdentifierValue(ROW_NUMBER_COLUMN_NAME)), null);
andPredicate.getPredicates().addAll(Collections.singleton(predicateSegment));
......@@ -103,7 +103,7 @@ public final class RowNumberPaginationContextEngineTest {
AndPredicate andPredicate = new AndPredicate();
andPredicate.getPredicates().add(new PredicateSegment(0, 10, new ColumnSegment(0, 10, new IdentifierValue(ROW_NUMBER_COLUMN_NAME)), predicateCompareRightValue));
Projection projectionWithRowNumberAlias = new ColumnProjection(null, ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias));
PaginationContext paginationContext = new RowNumberPaginationContextEngine()
.createPaginationContext(Collections.singleton(andPredicate), projectionsContext, Collections.singletonList(1));
......@@ -118,7 +118,7 @@ public final class RowNumberPaginationContextEngineTest {
AndPredicate andPredicate = new AndPredicate();
andPredicate.getPredicates().add(new PredicateSegment(0, 10, new ColumnSegment(0, 10, new IdentifierValue(ROW_NUMBER_COLUMN_NAME)), predicateCompareRightValue));
Projection projectionWithRowNumberAlias = new ColumnProjection(null, ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias));
PaginationContext paginationContext = new RowNumberPaginationContextEngine().createPaginationContext(Collections.singleton(andPredicate), projectionsContext, Collections.emptyList());
assertFalse(paginationContext.getOffsetSegment().isPresent());
......@@ -137,7 +137,7 @@ public final class RowNumberPaginationContextEngineTest {
AndPredicate andPredicate = new AndPredicate();
andPredicate.getPredicates().add(new PredicateSegment(0, 10, new ColumnSegment(0, 10, new IdentifierValue(ROW_NUMBER_COLUMN_NAME)), predicateCompareRightValue));
Projection projectionWithRowNumberAlias = new ColumnProjection(null, ROW_NUMBER_COLUMN_NAME, ROW_NUMBER_COLUMN_ALIAS);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singleton(projectionWithRowNumberAlias));
PaginationContext rowNumberPaginationContextEngine = new RowNumberPaginationContextEngine()
.createPaginationContext(Collections.singleton(andPredicate), projectionsContext, Collections.emptyList());
......
......@@ -38,46 +38,46 @@ public final class ProjectionsContextTest {
@Test
public void assertUnqualifiedShorthandProjectionWithEmptyItems() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.emptySet(), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.emptySet());
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
public void assertUnqualifiedShorthandProjectionWithWrongProjection() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(getColumnProjection()), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(getColumnProjection()));
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
public void assertUnqualifiedShorthandProjectionWithWrongShortProjection() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(getShorthandProjection()), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(getShorthandProjection()));
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
public void assertUnqualifiedShorthandProjection() {
Projection projection = new ShorthandProjection(null);
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection), Collections.emptyList());
Projection projection = new ShorthandProjection(null, Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection));
assertTrue(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
public void assertFindAliasWithOutAlias() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.emptyList(), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.emptyList());
assertFalse(projectionsContext.findAlias("").isPresent());
}
@Test
public void assertFindAlias() {
Projection projection = getColumnProjectionWithAlias();
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection));
assertTrue(projectionsContext.findAlias(projection.getExpression()).isPresent());
}
@Test
public void assertFindProjectionIndex() {
Projection projection = getColumnProjection();
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection));
Optional<Integer> actual = projectionsContext.findProjectionIndex(projection.getExpression());
assertTrue(actual.isPresent());
assertThat(actual.get(), is(1));
......@@ -86,7 +86,7 @@ public final class ProjectionsContextTest {
@Test
public void assertFindProjectionIndexFailure() {
Projection projection = getColumnProjection();
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, true, Collections.singleton(projection));
Optional<Integer> actual = projectionsContext.findProjectionIndex("");
assertFalse(actual.isPresent());
}
......@@ -94,7 +94,7 @@ public final class ProjectionsContextTest {
@Test
public void assertGetAggregationProjections() {
Projection projection = getAggregationProjection();
List<AggregationProjection> items = new ProjectionsContext(0, 0, true, Arrays.asList(projection, getColumnProjection()), Collections.emptyList()).getAggregationProjections();
List<AggregationProjection> items = new ProjectionsContext(0, 0, true, Arrays.asList(projection, getColumnProjection())).getAggregationProjections();
assertTrue(items.contains(projection));
assertThat(items.size(), is(1));
}
......@@ -102,13 +102,13 @@ public final class ProjectionsContextTest {
@Test
public void assertGetAggregationDistinctProjections() {
Projection projection = getAggregationDistinctProjection();
List<AggregationDistinctProjection> items = new ProjectionsContext(0, 0, true, Arrays.asList(projection, getColumnProjection()), Collections.emptyList()).getAggregationDistinctProjections();
List<AggregationDistinctProjection> items = new ProjectionsContext(0, 0, true, Arrays.asList(projection, getColumnProjection())).getAggregationDistinctProjections();
assertTrue(items.contains(projection));
assertThat(items.size(), is(1));
}
private ShorthandProjection getShorthandProjection() {
return new ShorthandProjection("table");
return new ShorthandProjection("table", Collections.emptyList());
}
private ColumnProjection getColumnProjection() {
......@@ -126,4 +126,12 @@ public final class ProjectionsContextTest {
private AggregationDistinctProjection getAggregationDistinctProjection() {
return new AggregationDistinctProjection(0, 0, AggregationType.COUNT, "(DISTINCT column)", "c", "column");
}
@Test
public void assertGetActualProjectionCount() {
ColumnProjection columnProjection = new ColumnProjection(null, "col", null);
ShorthandProjection shorthandProjection = new ShorthandProjection(null, Arrays.asList(new ColumnProjection(null, "col1", null), new ColumnProjection(null, "col2", null)));
ProjectionsContext actual = new ProjectionsContext(0, 0, false, Arrays.asList(columnProjection, shorthandProjection));
assertThat(actual.getActualProjectionCount(), is(3));
}
}
......@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sql.parser.relation.segment.select.projection.engine;
import org.apache.shardingsphere.sql.parser.core.constant.AggregationType;
import org.apache.shardingsphere.sql.parser.relation.metadata.RelationMetas;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.impl.AggregationDistinctProjection;
import org.apache.shardingsphere.sql.parser.relation.segment.select.projection.impl.AggregationProjection;
......@@ -35,25 +36,27 @@ import org.apache.shardingsphere.sql.parser.sql.segment.generic.OwnerSegment;
import org.apache.shardingsphere.sql.parser.sql.value.identifier.IdentifierValue;
import org.junit.Test;
import java.util.Collections;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentNotMatched() {
assertFalse(new ProjectionEngine().createProjection(null, null).isPresent());
assertFalse(new ProjectionEngine(mock(RelationMetas.class)).createProjection(null, Collections.emptyList(), null).isPresent());
}
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfShorthandProjectionSegment() {
ShorthandProjectionSegment shorthandProjectionSegment = new ShorthandProjectionSegment(0, 0, "text");
shorthandProjectionSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("tbl")));
Optional<Projection> actual = new ProjectionEngine().createProjection(null, shorthandProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection(null, Collections.emptyList(), shorthandProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ShorthandProjection.class));
}
......@@ -62,7 +65,7 @@ public final class ProjectionEngineTest {
public void assertCreateProjectionWhenProjectionSegmentInstanceOfColumnProjectionSegment() {
ColumnProjectionSegment columnProjectionSegment = new ColumnProjectionSegment("text", new ColumnSegment(0, 10, new IdentifierValue("name")));
columnProjectionSegment.setAlias(new AliasSegment(0, 0, new IdentifierValue("alias")));
Optional<Projection> actual = new ProjectionEngine().createProjection(null, columnProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection(null, Collections.emptyList(), columnProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ColumnProjection.class));
}
......@@ -70,7 +73,7 @@ public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfExpressionProjectionSegment() {
ExpressionProjectionSegment expressionProjectionSegment = new ExpressionProjectionSegment(0, 10, "text");
Optional<Projection> actual = new ProjectionEngine().createProjection(null, expressionProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection(null, Collections.emptyList(), expressionProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(ExpressionProjection.class));
}
......@@ -78,7 +81,7 @@ public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfAggregationDistinctProjectionSegment() {
AggregationDistinctProjectionSegment aggregationDistinctProjectionSegment = new AggregationDistinctProjectionSegment(0, 10, "text", AggregationType.COUNT, 0, "distinctExpression");
Optional<Projection> actual = new ProjectionEngine().createProjection("select count(1) from table_1", aggregationDistinctProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection("select count(1) from table_1", Collections.emptyList(), aggregationDistinctProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(AggregationDistinctProjection.class));
}
......@@ -86,7 +89,7 @@ public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfAggregationProjectionSegment() {
AggregationProjectionSegment aggregationProjectionSegment = new AggregationProjectionSegment(0, 10, "text", AggregationType.COUNT, 0);
Optional<Projection> actual = new ProjectionEngine().createProjection("select count(1) from table_1", aggregationProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection("select count(1) from table_1", Collections.emptyList(), aggregationProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(AggregationProjection.class));
}
......@@ -94,7 +97,7 @@ public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfAggregationDistinctProjectionSegmentAndAggregationTypeIsAvg() {
AggregationDistinctProjectionSegment aggregationDistinctProjectionSegment = new AggregationDistinctProjectionSegment(0, 10, "text", AggregationType.AVG, 0, "distinctExpression");
Optional<Projection> actual = new ProjectionEngine().createProjection("select count(1) from table_1", aggregationDistinctProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection("select count(1) from table_1", Collections.emptyList(), aggregationDistinctProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(AggregationDistinctProjection.class));
}
......@@ -102,7 +105,7 @@ public final class ProjectionEngineTest {
@Test
public void assertCreateProjectionWhenProjectionSegmentInstanceOfAggregationProjectionSegmentAndAggregationTypeIsAvg() {
AggregationProjectionSegment aggregationProjectionSegment = new AggregationProjectionSegment(0, 10, "text", AggregationType.AVG, 0);
Optional<Projection> actual = new ProjectionEngine().createProjection("select count(1) from table_1", aggregationProjectionSegment);
Optional<Projection> actual = new ProjectionEngine(mock(RelationMetas.class)).createProjection("select count(1) from table_1", Collections.emptyList(), aggregationProjectionSegment);
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(AggregationProjection.class));
}
......
......@@ -19,6 +19,8 @@ package org.apache.shardingsphere.sql.parser.relation.segment.select.projection.
import org.junit.Test;
import java.util.Collections;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
......@@ -28,21 +30,21 @@ public final class ShorthandProjectionTest {
@Test
public void assertGetExpression() {
assertThat(new ShorthandProjection("owner").getExpression(), is("owner.*"));
assertThat(new ShorthandProjection("owner", Collections.emptyList()).getExpression(), is("owner.*"));
}
@Test
public void assertGetAliasWhenAbsent() {
assertFalse(new ShorthandProjection("owner").getAlias().isPresent());
assertFalse(new ShorthandProjection("owner", Collections.emptyList()).getAlias().isPresent());
}
@Test
public void assertGetColumnLabel() {
assertTrue(new ShorthandProjection("owner").getColumnLabel().contains("*"));
assertTrue(new ShorthandProjection("owner", Collections.emptyList()).getColumnLabel().contains("*"));
}
@Test
public void assertContains() {
assertTrue(new ShorthandProjection("owner").getOwner().isPresent());
assertTrue(new ShorthandProjection("owner", Collections.emptyList()).getOwner().isPresent());
}
}
......@@ -22,7 +22,6 @@ import org.apache.shardingsphere.sql.parser.relation.statement.dml.InsertStateme
import org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.InsertValuesSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.column.InsertColumnsSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.ExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.simple.LiteralExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment;
......@@ -47,7 +46,7 @@ public final class InsertStatementContextTest {
new ColumnSegment(0, 0, new IdentifierValue("id")), new ColumnSegment(0, 0, new IdentifierValue("name")), new ColumnSegment(0, 0, new IdentifierValue("status"))));
insertStatement.setInsertColumns(insertColumnsSegment);
setUpInsertValues(insertStatement);
InsertStatementContext actual = new InsertStatementContext(mock(RelationMetas.class), Arrays.<Object>asList(1, "Tom", 2, "Jerry"), insertStatement);
InsertStatementContext actual = new InsertStatementContext(mock(RelationMetas.class), Arrays.asList(1, "Tom", 2, "Jerry"), insertStatement);
assertInsertStatementContext(actual);
}
......@@ -58,7 +57,7 @@ public final class InsertStatementContextTest {
InsertStatement insertStatement = new InsertStatement();
insertStatement.setTable(new SimpleTableSegment(0, 0, new IdentifierValue("tbl")));
setUpInsertValues(insertStatement);
InsertStatementContext actual = new InsertStatementContext(relationMetas, Arrays.<Object>asList(1, "Tom", 2, "Jerry"), insertStatement);
InsertStatementContext actual = new InsertStatementContext(relationMetas, Arrays.asList(1, "Tom", 2, "Jerry"), insertStatement);
assertInsertStatementContext(actual);
}
......@@ -69,25 +68,25 @@ public final class InsertStatementContextTest {
InsertStatement insertStatement = new InsertStatement();
insertStatement.setTable(new SimpleTableSegment(0, 0, new IdentifierValue("tbl")));
setUpInsertValues(insertStatement);
InsertStatementContext actual = new InsertStatementContext(relationMetas, Arrays.<Object>asList(1, "Tom", 2, "Jerry"), insertStatement);
InsertStatementContext actual = new InsertStatementContext(relationMetas, Arrays.asList(1, "Tom", 2, "Jerry"), insertStatement);
assertThat(actual.getGroupedParameters().size(), is(2));
}
private void setUpInsertValues(final InsertStatement insertStatement) {
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Arrays.<ExpressionSegment>asList(
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Arrays.asList(
new ParameterMarkerExpressionSegment(0, 0, 1), new ParameterMarkerExpressionSegment(0, 0, 2), new LiteralExpressionSegment(0, 0, "init"))));
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Arrays.<ExpressionSegment>asList(
insertStatement.getValues().add(new InsertValuesSegment(0, 0, Arrays.asList(
new ParameterMarkerExpressionSegment(0, 0, 3), new ParameterMarkerExpressionSegment(0, 0, 4), new LiteralExpressionSegment(0, 0, "init"))));
}
private void assertInsertStatementContext(final InsertStatementContext actual) {
assertThat(actual.getColumnNames(), is(Arrays.asList("id", "name", "status")));
assertThat(actual.getInsertValueContexts().size(), is(2));
assertThat(actual.getInsertValueContexts().get(0).getValue(0), is((Object) 1));
assertThat(actual.getInsertValueContexts().get(0).getValue(1), is((Object) "Tom"));
assertThat(actual.getInsertValueContexts().get(0).getValue(2), is((Object) "init"));
assertThat(actual.getInsertValueContexts().get(1).getValue(0), is((Object) 2));
assertThat(actual.getInsertValueContexts().get(1).getValue(1), is((Object) "Jerry"));
assertThat(actual.getInsertValueContexts().get(1).getValue(2), is((Object) "init"));
assertThat(actual.getInsertValueContexts().get(0).getValue(0), is(1));
assertThat(actual.getInsertValueContexts().get(0).getValue(1), is("Tom"));
assertThat(actual.getInsertValueContexts().get(0).getValue(2), is("init"));
assertThat(actual.getInsertValueContexts().get(1).getValue(0), is(2));
assertThat(actual.getInsertValueContexts().get(1).getValue(1), is("Jerry"));
assertThat(actual.getInsertValueContexts().get(1).getValue(2), is("init"));
}
}
......@@ -128,7 +128,7 @@ public final class SelectStatementContextTest {
public void assertSetIndexWhenAggregationProjectionsPresent() {
AggregationProjection aggregationProjection = new AggregationProjection(AggregationType.MAX, "", "id");
aggregationProjection.getDerivedAggregationProjections().addAll(Collections.singletonList(aggregationProjection));
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singletonList(aggregationProjection), Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0, false, Collections.singletonList(aggregationProjection));
SelectStatementContext selectStatementContext = new SelectStatementContext(
new SelectStatement(), new GroupByContext(Collections.emptyList(), 0), createOrderBy(COLUMN_ORDER_BY_WITHOUT_OWNER_ALIAS), projectionsContext, null);
......@@ -161,7 +161,7 @@ public final class SelectStatementContextTest {
private ProjectionsContext createProjectionsContext() {
return new ProjectionsContext(
0, 0, true, Arrays.asList(getColumnProjectionWithoutOwner(), getColumnProjectionWithoutOwner(true), getColumnProjectionWithoutOwner(false)), Collections.emptyList());
0, 0, true, Arrays.asList(getColumnProjectionWithoutOwner(), getColumnProjectionWithoutOwner(true), getColumnProjectionWithoutOwner(false)));
}
private Projection getColumnProjectionWithoutOwner() {
......
......@@ -89,11 +89,11 @@ public final class SQLServerDCLVisitor extends SQLServerVisitor implements DCLVi
}
private Collection<SimpleTableSegment> getTableFromPrivilegeClause(final ClassPrivilegesClauseContext ctx) {
return null == ctx.onClassClause().tableName() ? Collections.<SimpleTableSegment>emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onClassClause().tableName()));
return null == ctx.onClassClause().tableName() ? Collections.emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onClassClause().tableName()));
}
private Collection<SimpleTableSegment> getTableFromPrivilegeClause(final ClassTypePrivilegesClauseContext ctx) {
return null == ctx.onClassTypeClause().tableName() ? Collections.<SimpleTableSegment>emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onClassTypeClause().tableName()));
return null == ctx.onClassTypeClause().tableName() ? Collections.emptyList() : Collections.singletonList((SimpleTableSegment) visit(ctx.onClassTypeClause().tableName()));
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册