diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SubqueryFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SubqueryFiller.java
index 626310c0e4..3e4be81f64 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SubqueryFiller.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SubqueryFiller.java
@@ -19,6 +19,9 @@
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
+import io.shardingsphere.core.parsing.antlr.filler.impl.dql.GroupByFiller;
+import io.shardingsphere.core.parsing.antlr.filler.impl.dql.OrderByFiller;
+import io.shardingsphere.core.parsing.antlr.filler.impl.dql.SelectClauseFiller;
import io.shardingsphere.core.parsing.antlr.sql.segment.expr.SubquerySegment;
import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/GroupByFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/GroupByFiller.java
similarity index 88%
rename from sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/GroupByFiller.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/GroupByFiller.java
index dd8f4a1f14..54d40c1393 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/GroupByFiller.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/GroupByFiller.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.parsing.antlr.filler.impl;
+package io.shardingsphere.core.parsing.antlr.filler.impl.dql;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
@@ -36,9 +36,8 @@ public final class GroupByFiller implements SQLStatementFiller {
public void fill(final GroupBySegment sqlSegment, final SQLStatement sqlStatement, final String sql, final ShardingRule shardingRule, final ShardingTableMetaData shardingTableMetaData) {
SelectStatement selectStatement = (SelectStatement) sqlStatement;
selectStatement.setGroupByLastPosition(sqlSegment.getGroupByLastPosition());
- OrderByFiller orderFiller = new OrderByFiller();
for (OrderByItemSegment each : sqlSegment.getGroupByItems()) {
- selectStatement.getGroupByItems().add(orderFiller.createOrderItem(selectStatement, each));
+ selectStatement.getGroupByItems().add(new OrderItemBuilder(selectStatement, each).createOrderItem());
}
}
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/LimitFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/LimitFiller.java
similarity index 97%
rename from sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/LimitFiller.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/LimitFiller.java
index 2080f45f89..120859b2af 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/LimitFiller.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/LimitFiller.java
@@ -15,7 +15,7 @@
*
*/
-package io.shardingsphere.core.parsing.antlr.filler.impl;
+package io.shardingsphere.core.parsing.antlr.filler.impl.dql;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderByFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderByFiller.java
new file mode 100644
index 0000000000..db6fa0f190
--- /dev/null
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderByFiller.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016-2018 shardingsphere.io.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingsphere.core.parsing.antlr.filler.impl.dql;
+
+import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
+import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
+import io.shardingsphere.core.parsing.antlr.sql.segment.order.OrderBySegment;
+import io.shardingsphere.core.parsing.antlr.sql.segment.order.item.OrderByItemSegment;
+import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
+import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
+import io.shardingsphere.core.rule.ShardingRule;
+
+/**
+ * Order by filler.
+ *
+ * @author duhongjun
+ */
+public final class OrderByFiller implements SQLStatementFiller {
+
+ @Override
+ public void fill(final OrderBySegment sqlSegment, final SQLStatement sqlStatement, final String sql, final ShardingRule shardingRule, final ShardingTableMetaData shardingTableMetaData) {
+ SelectStatement selectStatement = (SelectStatement) sqlStatement;
+ if (!selectStatement.getSubQueryStatements().isEmpty()) {
+ return;
+ }
+ for (OrderByItemSegment each : sqlSegment.getOrderByItems()) {
+ selectStatement.getOrderByItems().add(new OrderItemBuilder(selectStatement, each).createOrderItem());
+ }
+ }
+}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/OrderByFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderItemBuilder.java
similarity index 76%
rename from sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/OrderByFiller.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderItemBuilder.java
index 136e6009d9..f380e2adcb 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/OrderByFiller.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/OrderItemBuilder.java
@@ -15,52 +15,40 @@
*
*/
-package io.shardingsphere.core.parsing.antlr.filler.impl;
+package io.shardingsphere.core.parsing.antlr.filler.impl.dql;
import com.google.common.base.Optional;
import com.google.common.base.Splitter;
-import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
-import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
-import io.shardingsphere.core.parsing.antlr.sql.segment.order.OrderBySegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.order.item.ColumnNameOrderByItemSegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.order.item.ExpressionOrderByItemSegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.order.item.IndexOrderByItemSegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.order.item.OrderByItemSegment;
import io.shardingsphere.core.parsing.parser.context.orderby.OrderItem;
-import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
import io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement;
import io.shardingsphere.core.parsing.parser.token.TableToken;
-import io.shardingsphere.core.rule.ShardingRule;
import io.shardingsphere.core.util.SQLUtil;
+import lombok.RequiredArgsConstructor;
import java.util.List;
/**
- * Order by filler.
+ * Order item builder.
*
- * @author duhongjun
+ * @author zhangliang
*/
-public final class OrderByFiller implements SQLStatementFiller {
+@RequiredArgsConstructor
+public final class OrderItemBuilder {
- @Override
- public void fill(final OrderBySegment sqlSegment, final SQLStatement sqlStatement, final String sql, final ShardingRule shardingRule, final ShardingTableMetaData shardingTableMetaData) {
- SelectStatement selectStatement = (SelectStatement) sqlStatement;
- if (!selectStatement.getSubQueryStatements().isEmpty()) {
- return;
- }
- for (OrderByItemSegment each : sqlSegment.getOrderByItems()) {
- selectStatement.getOrderByItems().add(createOrderItem(selectStatement, each));
- }
- }
+ private final SelectStatement selectStatement;
+
+ private final OrderByItemSegment orderByItemSegment;
/**
- * create order item.
+ * Create order item.
*
- * @param selectStatement select statement
- * @param orderByItemSegment order by item segment
* @return order item
*/
- public OrderItem createOrderItem(final SelectStatement selectStatement, final OrderByItemSegment orderByItemSegment) {
+ public OrderItem createOrderItem() {
if (orderByItemSegment instanceof IndexOrderByItemSegment) {
return createOrderItem((IndexOrderByItemSegment) orderByItemSegment);
}
diff --git a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SelectClauseFiller.java b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/SelectClauseFiller.java
similarity index 98%
rename from sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SelectClauseFiller.java
rename to sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/SelectClauseFiller.java
index 79b07debaf..3de42bf052 100644
--- a/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/SelectClauseFiller.java
+++ b/sharding-core/src/main/java/io/shardingsphere/core/parsing/antlr/filler/impl/dql/SelectClauseFiller.java
@@ -15,11 +15,12 @@
*
*/
-package io.shardingsphere.core.parsing.antlr.filler.impl;
+package io.shardingsphere.core.parsing.antlr.filler.impl.dql;
import com.google.common.base.Optional;
import io.shardingsphere.core.metadata.table.ShardingTableMetaData;
import io.shardingsphere.core.parsing.antlr.filler.SQLStatementFiller;
+import io.shardingsphere.core.parsing.antlr.filler.impl.ExpressionFiller;
import io.shardingsphere.core.parsing.antlr.sql.segment.SelectClauseSegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.expr.CommonExpressionSegment;
import io.shardingsphere.core.parsing.antlr.sql.segment.expr.ExpressionSegment;
diff --git a/sharding-core/src/main/resources/META-INF/parsing-rule-definition/common/filler-rule-definition.xml b/sharding-core/src/main/resources/META-INF/parsing-rule-definition/common/filler-rule-definition.xml
index 0873eb9df3..18ac1ff559 100644
--- a/sharding-core/src/main/resources/META-INF/parsing-rule-definition/common/filler-rule-definition.xml
+++ b/sharding-core/src/main/resources/META-INF/parsing-rule-definition/common/filler-rule-definition.xml
@@ -10,12 +10,12 @@
-
+
-
-
-
+
+
+