tristaZero commented on a change in pull request #10816:
URL: https://github.com/apache/shardingsphere/pull/10816#discussion_r651725673
##########
File path:
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexToken.java
##########
@@ -62,7 +63,12 @@ public IndexToken(final int startIndex, final int stopIndex,
final IdentifierVal
@Override
public String toString(final RouteUnit routeUnit) {
- return identifier.getQuoteCharacter().wrap(getIndexValue(routeUnit));
+ String quotedIndexName =
identifier.getQuoteCharacter().wrap(getIndexValue(routeUnit));
+ return isGeneratedIndex() ? " " + quotedIndexName + " " :
quotedIndexName;
Review comment:
Will it be better to move blank space to the outer?
##########
File path:
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateIndexStatementValidator.java
##########
@@ -38,7 +39,9 @@ public void preValidate(final ShardingRule shardingRule,
final SQLStatementConte
final List<Object> parameters, final
ShardingSphereSchema schema) {
validateTableExist(schema,
Collections.singletonList(sqlStatementContext.getSqlStatement().getTable()));
String tableName =
sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
- String indexName =
sqlStatementContext.getSqlStatement().getIndex().getIdentifier().getValue();
+ String indexName = null !=
sqlStatementContext.getSqlStatement().getIndex()
+ ?
sqlStatementContext.getSqlStatement().getIndex().getIdentifier().getValue()
+ :
IndexMetaDataUtil.getGeneratedLogicIndexName(sqlStatementContext.getSqlStatement().getColumns());
Review comment:
How about `sqlStatementContext.getIndexName()`?
##########
File path:
shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/ddl/CreateIndexStatementContext.java
##########
@@ -49,6 +56,10 @@ public CreateIndexStatementContext(final
CreateIndexStatement sqlStatement) {
@Override
public Collection<IndexSegment> getIndexes() {
- return null == getSqlStatement().getIndex() ? Collections.emptyList()
: Collections.singletonList(getSqlStatement().getIndex());
+ Optional<Integer> startIndex =
CreateIndexStatementHandler.getGeneratedIndexStartIndex(getSqlStatement());
+ String generatedLogicIndexName =
IndexMetaDataUtil.getGeneratedLogicIndexName(getSqlStatement().getColumns());
+ Collection<IndexSegment> generatedIndexSegments = startIndex.map(index
-> Collections.singletonList(new IndexSegment(index, index,
Review comment:
if (null != getSqlStatement().getIndex()) {
return
}
Collection<IndexSegment> generatedIndexSegments =xxx;
return?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]