mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Simple key dictionary primary key wrong order fix
This commit is contained in:
parent
8b3c37e648
commit
b26dfcd514
@ -307,7 +307,22 @@ void buildPrimaryKeyConfiguration(
|
||||
AutoPtr<Element> name_element(doc->createElement("name"));
|
||||
id_element->appendChild(name_element);
|
||||
|
||||
const ASTDictionaryAttributeDeclaration * dict_attr = children.front()->as<const ASTDictionaryAttributeDeclaration>();
|
||||
auto identifier_name = key_names.front();
|
||||
|
||||
auto it = std::find_if(children.begin(), children.end(), [&](const ASTPtr & node)
|
||||
{
|
||||
const ASTDictionaryAttributeDeclaration * dict_attr = node->as<const ASTDictionaryAttributeDeclaration>();
|
||||
return dict_attr->name == identifier_name;
|
||||
});
|
||||
|
||||
if (it == children.end())
|
||||
{
|
||||
throw Exception(ErrorCodes::INCORRECT_DICTIONARY_DEFINITION,
|
||||
"Primary key field '{}' not found among attributes",
|
||||
identifier_name);
|
||||
}
|
||||
|
||||
const ASTDictionaryAttributeDeclaration * dict_attr = (*it)->as<const ASTDictionaryAttributeDeclaration>();
|
||||
|
||||
AutoPtr<Text> name(doc->createTextNode(dict_attr->name));
|
||||
name_element->appendChild(name);
|
||||
|
@ -0,0 +1 @@
|
||||
1 20
|
@ -0,0 +1,24 @@
|
||||
DROP TABLE IF EXISTS dictionary_primary_key_source_table;
|
||||
CREATE TABLE dictionary_primary_key_source_table
|
||||
(
|
||||
identifier UInt64,
|
||||
v UInt64
|
||||
) ENGINE = TinyLog;
|
||||
|
||||
INSERT INTO dictionary_primary_key_source_table VALUES (20, 1);
|
||||
|
||||
DROP DICTIONARY IF EXISTS flat_dictionary;
|
||||
CREATE DICTIONARY flat_dictionary
|
||||
(
|
||||
identifier UInt64,
|
||||
v UInt64
|
||||
)
|
||||
PRIMARY KEY v
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() TABLE 'dictionary_primary_key_source_table'))
|
||||
LIFETIME(MIN 1 MAX 1000)
|
||||
LAYOUT(FLAT());
|
||||
|
||||
SELECT * FROM flat_dictionary;
|
||||
|
||||
DROP DICTIONARY flat_dictionary;
|
||||
DROP TABLE dictionary_primary_key_source_table;
|
Loading…
Reference in New Issue
Block a user