diff --git a/src/Functions/FunctionsExternalDictionaries.h b/src/Functions/FunctionsExternalDictionaries.h index ac59775a755..6e7aff2ceba 100644 --- a/src/Functions/FunctionsExternalDictionaries.h +++ b/src/Functions/FunctionsExternalDictionaries.h @@ -361,6 +361,13 @@ public: /// Functions in external dictionaries_loader only support full-value (not constant) columns with keys. ColumnPtr key_column_full = key_col_with_type.column->convertToFullColumnIfConst(); + if (!isTuple(key_col_with_type.type)) + throw Exception( + ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, + "Third argument of function ({}) must be tuple when dictionary is complex. Actual type ({}).", + getName(), + key_col_with_type.type->getName()); + const auto & key_columns = typeid_cast(*key_column_full).getColumnsCopy(); const auto & key_types = static_cast(*key_col_with_type.type).getElements(); diff --git a/tests/config/executable_pool_dictionary.xml b/tests/config/executable_pool_dictionary.xml new file mode 100644 index 00000000000..13f34f0048e --- /dev/null +++ b/tests/config/executable_pool_dictionary.xml @@ -0,0 +1,154 @@ + + + + executable_pool_simple + + + + x + + + a + String + + + + b + String + + + + + + + TabSeparated + while read read_data; do printf "$read_data\t$read_data a\t$read_data b\n"; done + 5 + + + + + + + + 300 + + + + executable_pool_complex + + + + + x + String + + + y + String + + + + a + String + + + + b + String + + + + + + + TabSeparated + while read read_data; do printf "$read_data\tvalue a\tvalue b\n"; done + + + + + + + + 300 + + + + executable_pool_simple_implicit_key + + + + x + + + a + String + + + + b + String + + + + + + + TabSeparated + while read read_data; do printf "$read_data a\t$read_data b\n"; done + 5 + true + + + + + + + + 300 + + + + executable_pool_complex_implicit_key + + + + + x + String + + + y + String + + + + a + String + + + + b + String + + + + + + + TabSeparated + while read read_data; do printf "data a\tdata b\n"; done + 5 + true + + + + + + + + 300 + + + diff --git a/tests/queries/0_stateless/01746_executable_pool_dictionary.reference b/tests/queries/0_stateless/01746_executable_pool_dictionary.reference new file mode 100644 index 00000000000..cf79a75e3f1 --- /dev/null +++ b/tests/queries/0_stateless/01746_executable_pool_dictionary.reference @@ -0,0 +1,10 @@ +executable_pool_simple +1 a +1 b +2 a +2 b +executable_pool_complex +value a +value b +value a +value b diff --git a/tests/queries/0_stateless/01746_executable_pool_dictionary.sql b/tests/queries/0_stateless/01746_executable_pool_dictionary.sql new file mode 100644 index 00000000000..aa59d209b51 --- /dev/null +++ b/tests/queries/0_stateless/01746_executable_pool_dictionary.sql @@ -0,0 +1,15 @@ +SELECT 'executable_pool_simple'; + +SELECT dictGet('executable_pool_simple', 'a', toUInt64(1)); +SELECT dictGet('executable_pool_simple', 'b', toUInt64(1)); + +SELECT dictGet('executable_pool_simple', 'a', toUInt64(2)); +SELECT dictGet('executable_pool_simple', 'b', toUInt64(2)); + +SELECT 'executable_pool_complex'; + +SELECT dictGet('executable_pool_complex', 'a', ('First_1', 'Second_1')); +SELECT dictGet('executable_pool_complex', 'b', ('First_1', 'Second_1')); + +SELECT dictGet('executable_pool_complex', 'a', ('First_2', 'Second_2')); +SELECT dictGet('executable_pool_complex', 'b', ('First_2', 'Second_2')); diff --git a/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.reference b/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.reference new file mode 100644 index 00000000000..ab44ba51330 --- /dev/null +++ b/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.reference @@ -0,0 +1,10 @@ +executable_pool_simple_implicit_key +1 a +1 b +2 a +2 b +executable_pool_complex_implicit_key +data a +data b +data a +data b diff --git a/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.sql b/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.sql new file mode 100644 index 00000000000..6c6d33c7d43 --- /dev/null +++ b/tests/queries/0_stateless/01747_executable_pool_dictionary_implicit_key.sql @@ -0,0 +1,15 @@ +SELECT 'executable_pool_simple_implicit_key'; + +SELECT dictGet('executable_pool_simple_implicit_key', 'a', toUInt64(1)); +SELECT dictGet('executable_pool_simple_implicit_key', 'b', toUInt64(1)); + +SELECT dictGet('executable_pool_simple_implicit_key', 'a', toUInt64(2)); +SELECT dictGet('executable_pool_simple_implicit_key', 'b', toUInt64(2)); + +SELECT 'executable_pool_complex_implicit_key'; + +SELECT dictGet('executable_pool_complex_implicit_key', 'a', ('First_1', 'Second_1')); +SELECT dictGet('executable_pool_complex_implicit_key', 'b', ('First_1', 'Second_1')); + +SELECT dictGet('executable_pool_complex_implicit_key', 'a', ('First_2', 'Second_2')); +SELECT dictGet('executable_pool_complex_implicit_key', 'b', ('First_2', 'Second_2'));