未验证 提交 dcabbc95 编写于 作者: M Maksim Kita 提交者: GitHub

Merge pull request #20623 from kitaisreal/dictionary-create-source-with-functions-fix

Dictionary create source with functions crash fix
......@@ -401,10 +401,16 @@ void buildConfigurationFromFunctionWithKeyValueArguments(
{
auto builder = FunctionFactory::instance().tryGet(func->name, context);
auto function = builder->build({});
auto result = function->execute({}, {}, 0);
function->prepare({});
/// We assume that function will not take arguments and will return constant value like tcpPort or hostName
/// Such functions will return column with size equal to input_rows_count.
size_t input_rows_count = 1;
auto result = function->execute({}, function->getResultType(), input_rows_count);
Field value;
result->get(0, value);
AutoPtr<Text> text_value(doc->createTextNode(getFieldAsString(value)));
current_xml_element->appendChild(text_value);
}
......
DROP DATABASE IF EXISTS 01720_dictionary_db;
CREATE DATABASE 01720_dictionary_db;
CREATE TABLE 01720_dictionary_db.dictionary_source_table
(
key UInt8,
value String
)
ENGINE = TinyLog;
INSERT INTO 01720_dictionary_db.dictionary_source_table VALUES (1, 'First');
CREATE DICTIONARY 01720_dictionary_db.dictionary
(
key UInt64,
value String
)
PRIMARY KEY key
SOURCE(CLICKHOUSE(DB '01720_dictionary_db' TABLE 'dictionary_source_table' HOST hostName() PORT tcpPort()))
LIFETIME(0)
LAYOUT(FLAT());
SELECT * FROM 01720_dictionary_db.dictionary;
DROP DICTIONARY 01720_dictionary_db.dictionary;
DROP TABLE 01720_dictionary_db.dictionary_source_table;
DROP DATABASE 01720_dictionary_db;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册