-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support drop index sql bind and add test case. (#34165)
* Support GroupConcat sql for aggregating multiple shards(#33797) * Check Style fix(#33797) * Check Style fix(#33797) * spotless fix (#33797) * unit test fix (#33797) * spotless fix (#33797) * group_concat distinct compatible (#33797) * group_concat distinct compatible (#33797) * unit test fix for distinct group_concat (#33797) * e2e test for group_concat (#33797) * e2e test for group_concat (#33797) * code format (#33797) * e2e test (#33797) * e2e test (#33797) * e2e test (#33797) * remove useless code(#33797) * code optimization (#33797) * sql parse unit test (#33797) * RELEASE-NOTES.md updated(#33797) * Code Optimization (#33797) * Support GroupConcat sql for aggregating multiple shards in opengauss and doris database(#33797) * doris parse unit test fix (#33797) * spotless fix (#33797) * Update RELEASE-NOTES.md * Add DBCOMPATIBILITY 'B' parameter to opengauss database (#33992) * Add DBCOMPATIBILITY 'B' parameter to opengauss database for dbtbl_with_readwrite_splitting and readwrite_splitting scenarios(#33992) * add openGauss test case for group_concat. (#33992) * Support drop index sql bind and add test case. --------- Co-authored-by: yaofly <[email protected]> Co-authored-by: Zhengqiang Duan <[email protected]>
- Loading branch information
1 parent
ad02d16
commit 1073a04
Showing
7 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...org/apache/shardingsphere/infra/binder/engine/statement/ddl/DropIndexStatementBinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.shardingsphere.infra.binder.engine.statement.ddl; | ||
|
||
import com.cedarsoftware.util.CaseInsensitiveMap; | ||
import com.google.common.collect.LinkedHashMultimap; | ||
import com.google.common.collect.Multimap; | ||
import lombok.SneakyThrows; | ||
import org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext; | ||
import org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder; | ||
import org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinder; | ||
import org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext; | ||
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropIndexStatement; | ||
|
||
/** | ||
* Drop index statement binder. | ||
*/ | ||
public class DropIndexStatementBinder implements SQLStatementBinder<DropIndexStatement> { | ||
|
||
@Override | ||
public DropIndexStatement bind(final DropIndexStatement sqlStatement, final SQLStatementBinderContext binderContext) { | ||
if (!sqlStatement.getSimpleTable().isPresent()) { | ||
return sqlStatement; | ||
} | ||
DropIndexStatement result = copy(sqlStatement); | ||
Multimap<CaseInsensitiveMap.CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create(); | ||
result.setSimpleTable(SimpleTableSegmentBinder.bind(sqlStatement.getSimpleTable().get(), binderContext, tableBinderContexts)); | ||
sqlStatement.getIndexes().forEach(each -> result.getIndexes().add(each)); | ||
return result; | ||
} | ||
|
||
@SneakyThrows(ReflectiveOperationException.class) | ||
private static DropIndexStatement copy(final DropIndexStatement sqlStatement) { | ||
DropIndexStatement result = sqlStatement.getClass().getDeclaredConstructor().newInstance(); | ||
sqlStatement.getSimpleTable().ifPresent(result::setSimpleTable); | ||
sqlStatement.getAlgorithmType().ifPresent(result::setAlgorithmType); | ||
sqlStatement.getLockTable().ifPresent(result::setLockTable); | ||
result.setIfExists(sqlStatement.isIfExists()); | ||
result.addParameterMarkerSegments(sqlStatement.getParameterMarkerSegments()); | ||
result.getCommentSegments().addAll(sqlStatement.getCommentSegments()); | ||
result.getVariableNames().addAll(sqlStatement.getVariableNames()); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/it/binder/src/test/resources/cases/ddl/drop-index.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You 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. | ||
--> | ||
|
||
<sql-parser-test-cases> | ||
<drop-index sql-case-id="drop_index"> | ||
<index name="idx_user_id" start-index="11" stop-index="21"/> | ||
<table name="t_order" start-index="26" stop-index="32"> | ||
<table-bound> | ||
<original-database name="foo_db_1"/> | ||
<original-schema name="foo_db_1"/> | ||
</table-bound> | ||
</table> | ||
</drop-index> | ||
<drop-index sql-case-id="drop_index_for_sqlserver"> | ||
<index name="idx_user_id" start-index="11" stop-index="21"/> | ||
<table name="t_order" start-index="26" stop-index="32"> | ||
<table-bound> | ||
<original-database name="foo_db_1"/> | ||
<original-schema name="dbo"/> | ||
</table-bound> | ||
</table> | ||
</drop-index> | ||
<drop-index sql-case-id="drop_index_with_lock_algorithm"> | ||
<index name="idx_user_id" start-index="11" stop-index="21"/> | ||
<table name="t_order" start-index="26" stop-index="32"> | ||
<table-bound> | ||
<original-database name="foo_db_1"/> | ||
<original-schema name="foo_db_1"/> | ||
</table-bound> | ||
</table> | ||
<lock-option type="SHARED" start-index="40" stop-index="50"/> | ||
<algorithm-option type="COPY" start-index="52" stop-index="65"/> | ||
</drop-index> | ||
</sql-parser-test-cases> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You 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. | ||
--> | ||
|
||
<sql-cases> | ||
<sql-case id="drop_index" value="DROP INDEX idx_user_id ON t_order" db-types="MySQL,Doris" /> | ||
<sql-case id="drop_index_for_sqlserver" value="DROP INDEX idx_user_id ON t_order" db-types="SQLServer" /> | ||
<sql-case id="drop_index_with_lock_algorithm" value="DROP INDEX idx_user_id ON t_order LOCK=SHARED ALGORITHM=COPY" db-types="MySQL,Doris" /> | ||
</sql-cases> |