Merge pull request #31800 from kitaisreal/dict-get-with-type-nullable-fix

Function dictGet with type Nullable fix
This commit is contained in:
Maksim Kita 2021-12-02 12:27:47 +03:00 committed by GitHub
commit a426ed0a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 6 deletions

View File

@ -662,18 +662,13 @@ private:
{
auto return_type = impl.getReturnTypeImpl(arguments);
if (!areTypesEqual(return_type, result_type))
if (!return_type->equals(*result_type))
throw Exception{"Dictionary attribute has different type " + return_type->getName() + " expected " + result_type->getName(),
ErrorCodes::TYPE_MISMATCH};
return impl.executeImpl(arguments, return_type, input_rows_count);
}
static bool areTypesEqual(const DataTypePtr & lhs, const DataTypePtr & rhs)
{
return removeNullable(recursiveRemoveLowCardinality(lhs))->equals(*removeNullable(recursiveRemoveLowCardinality(rhs)));
}
const FunctionDictGetNoType<dictionary_get_function_type> impl;
};

View File

@ -0,0 +1 @@
Value

View File

@ -0,0 +1,22 @@
DROP TABLE IF EXISTS 02125_test_table;
CREATE TABLE 02125_test_table
(
id UInt64,
value Nullable(String)
)
ENGINE=TinyLog;
INSERT INTO 02125_test_table VALUES (0, 'Value');
DROP DICTIONARY IF EXISTS 02125_test_dictionary;
CREATE DICTIONARY 02125_test_dictionary
(
id UInt64,
value Nullable(String)
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(TABLE '02125_test_table'))
LAYOUT(DIRECT());
SELECT dictGet('02125_test_dictionary', 'value', toUInt64(0));
SELECT dictGetString('02125_test_dictionary', 'value', toUInt64(0)); --{serverError 53}