mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
if the data type of numeric key is not native uint, convert to complex.
This commit is contained in:
parent
dc3aca6e98
commit
f9eb6ca6fd
@ -19,6 +19,7 @@
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <Common/isLocalAddress.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -609,17 +610,20 @@ getDictionaryConfigurationFromAST(const ASTCreateQuery & query, ContextPtr conte
|
||||
|
||||
bool complex = DictionaryFactory::instance().isComplex(dictionary_layout->layout_type);
|
||||
|
||||
if (pk_attrs.size() > 1 && !complex
|
||||
&& DictionaryFactory::instance().convertToComplex(dictionary_layout->layout_type))
|
||||
{
|
||||
complex = true;
|
||||
}
|
||||
|
||||
auto all_attr_names_and_types = buildDictionaryAttributesConfiguration(
|
||||
xml_document, structure_element, query.dictionary_attributes_list, pk_attrs);
|
||||
|
||||
checkPrimaryKey(all_attr_names_and_types, pk_attrs);
|
||||
|
||||
/// If the pk size is 1 and pk's DataType is not native uint(UInt8~UInt64), we should convert to complex,
|
||||
/// because the data type of Numeric key(simple layout) is UInt64.
|
||||
if ((pk_attrs.size() > 1 || (pk_attrs.size() == 1 && !WhichDataType(DataTypeFactory::instance().get(all_attr_names_and_types.find(pk_attrs[0])->second.type)).isNativeUInt()))
|
||||
&& !complex
|
||||
&& DictionaryFactory::instance().convertToComplex(dictionary_layout->layout_type))
|
||||
{
|
||||
complex = true;
|
||||
}
|
||||
|
||||
buildPrimaryKeyConfiguration(xml_document, structure_element, complex, pk_attrs, query.dictionary_attributes_list);
|
||||
|
||||
buildLayoutConfiguration(xml_document, current_dictionary, query.dictionary->dict_settings, dictionary_layout);
|
||||
|
@ -2,3 +2,4 @@ dict_flat_simple Flat
|
||||
dict_hashed_simple Hashed
|
||||
dict_hashed_complex ComplexKeyHashed
|
||||
dict_hashed_simple_auto_convert ComplexKeyHashed
|
||||
dict_hashed_simple_int_auto_convert ComplexKeyHashed
|
||||
|
@ -26,4 +26,9 @@ SYSTEM RELOAD DICTIONARY dict_hashed_simple_auto_convert;
|
||||
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_hashed_simple_auto_convert';
|
||||
DROP DICTIONARY dict_hashed_simple_auto_convert;
|
||||
|
||||
CREATE DICTIONARY dict_hashed_simple_int_auto_convert (v0 Int16, v1 UInt16, v2 UInt16) PRIMARY KEY v0 SOURCE(CLICKHOUSE(TABLE 'dict_data')) LIFETIME(0) LAYOUT(hashed());
|
||||
SYSTEM RELOAD DICTIONARY dict_hashed_simple_int_auto_convert;
|
||||
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_hashed_simple_int_auto_convert';
|
||||
DROP DICTIONARY dict_hashed_simple_int_auto_convert;
|
||||
|
||||
DROP TABLE dict_data;
|
||||
|
Loading…
Reference in New Issue
Block a user