mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #54791 from hanfei1991/hanfei/duplicate_index
refine error code of duplicated index in create query
This commit is contained in:
commit
923ffe412f
@ -95,6 +95,7 @@ namespace ErrorCodes
|
||||
extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY;
|
||||
extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
extern const int ILLEGAL_INDEX;
|
||||
extern const int LOGICAL_ERROR;
|
||||
extern const int UNKNOWN_DATABASE;
|
||||
extern const int PATH_ACCESS_DENIED;
|
||||
@ -697,6 +698,8 @@ InterpreterCreateQuery::TableProperties InterpreterCreateQuery::getTableProperti
|
||||
for (const auto & index : create.columns_list->indices->children)
|
||||
{
|
||||
IndexDescription index_desc = IndexDescription::getIndexFromAST(index->clone(), properties.columns, getContext());
|
||||
if (properties.indices.has(index_desc.name))
|
||||
throw Exception(ErrorCodes::ILLEGAL_INDEX, "Duplicated index name {}", backQuoteIfNeed(index_desc.name));
|
||||
const auto & settings = getContext()->getSettingsRef();
|
||||
if (index_desc.type == INVERTED_INDEX_NAME && !settings.allow_experimental_inverted_index)
|
||||
{
|
||||
@ -711,6 +714,7 @@ InterpreterCreateQuery::TableProperties InterpreterCreateQuery::getTableProperti
|
||||
|
||||
properties.indices.push_back(index_desc);
|
||||
}
|
||||
|
||||
if (create.columns_list->projections)
|
||||
for (const auto & projection_ast : create.columns_list->projections->children)
|
||||
{
|
||||
|
10
tests/queries/0_stateless/02884_duplicate_index_name.sql
Normal file
10
tests/queries/0_stateless/02884_duplicate_index_name.sql
Normal file
@ -0,0 +1,10 @@
|
||||
DROP TABLE IF EXISTS test_dup_index;
|
||||
|
||||
CREATE TABLE test_dup_index
|
||||
(
|
||||
a Int64,
|
||||
b Int64,
|
||||
INDEX idx_a a TYPE minmax,
|
||||
INDEX idx_a b TYPE minmax
|
||||
) Engine = MergeTree()
|
||||
ORDER BY a; -- { serverError ILLEGAL_INDEX }
|
Loading…
Reference in New Issue
Block a user