Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ public void dropIndexPolicy(boolean isIfExists, String indexPolicyName,
}
throw new DdlException("index policy " + indexPolicyName + " does not exist");
}
if (policyToDrop.getType() != type) {
throw new DdlException("Cannot drop " + policyToDrop.getType() + " policy '"
+ indexPolicyName + "' by DROP " + type + " statement.");
}
if (policyToDrop.getType() == IndexPolicyTypeEnum.ANALYZER) {
checkAnalyzerNotUsedByIndex(policyToDrop.getName());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

suite("test_index_policy_drop") {
def tokenizerName = "test_tokenizer_drop_check"

// 1. Create a tokenizer policy
sql "DROP INVERTED INDEX TOKENIZER IF EXISTS ${tokenizerName}"
sql """
CREATE INVERTED INDEX TOKENIZER ${tokenizerName}
PROPERTIES("type" = "pinyin")
"""

// 2. Attempt to drop it using DROP ANALYZER syntax (should fail)
test {
sql "DROP INVERTED INDEX ANALYZER ${tokenizerName}"
exception "Cannot drop TOKENIZER policy '${tokenizerName}' by DROP ANALYZER statement"
}

// 3. Drop it using correct syntax (should succeed)
sql "DROP INVERTED INDEX TOKENIZER ${tokenizerName}"
}
Loading