mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-15 12:14:18 +00:00
Address review
This commit is contained in:
parent
1c6e7d1ab3
commit
ef3102b09c
@ -38,6 +38,7 @@ namespace DB
|
||||
{
|
||||
namespace Setting
|
||||
{
|
||||
extern const SettingsBool enable_named_columns_in_function_tuple;
|
||||
extern const SettingsBool transform_null_in;
|
||||
}
|
||||
|
||||
@ -182,26 +183,29 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
/// Function "tuple" which generates named tuple should use argument aliases to construct its name.
|
||||
if (function_node.getFunctionName() == "tuple")
|
||||
if (planner_context.getQueryContext()->getSettingsRef()[Setting::enable_named_columns_in_function_tuple])
|
||||
{
|
||||
if (const DataTypeTuple * type_tuple = typeid_cast<const DataTypeTuple *>(function_node.getResultType().get()))
|
||||
/// Function "tuple" which generates named tuple should use argument aliases to construct its name.
|
||||
if (function_node.getFunctionName() == "tuple")
|
||||
{
|
||||
if (type_tuple->haveExplicitNames())
|
||||
if (const DataTypeTuple * type_tuple = typeid_cast<const DataTypeTuple *>(function_node.getResultType().get()))
|
||||
{
|
||||
const auto & names = type_tuple->getElementNames();
|
||||
size_t size = names.size();
|
||||
WriteBufferFromOwnString s;
|
||||
s << "tuple(";
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
if (type_tuple->haveExplicitNames())
|
||||
{
|
||||
if (i != 0)
|
||||
s << ", ";
|
||||
s << names[i];
|
||||
const auto & names = type_tuple->getElementNames();
|
||||
size_t size = names.size();
|
||||
WriteBufferFromOwnString s;
|
||||
s << "tuple(";
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
if (i != 0)
|
||||
s << ", ";
|
||||
s << names[i];
|
||||
}
|
||||
s << ")";
|
||||
result = s.str();
|
||||
break;
|
||||
}
|
||||
s << ")";
|
||||
result = s.str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
1 ('dete','ok') ('dete','ok')
|
||||
{"id":1,"a":{"col_a":"dete","type":"ok"},"b":{"col_b":"dete","type":"ok"}}
|
||||
{"id":1,"a":{"col_a":"dete","type":"ok"},"b":{"col_b":"dete","type":"ok"}}
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET enable_named_columns_in_function_tuple = 1;
|
||||
|
||||
DROP TABLE IF EXISTS src;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
|
||||
@ -10,3 +12,10 @@ SELECT * FROM dst;
|
||||
|
||||
DROP TABLE src;
|
||||
DROP TABLE dst;
|
||||
|
||||
DROP TABLE IF EXISTS src;
|
||||
CREATE TABLE src (id UInt32, type String, data String) ENGINE=MergeTree ORDER BY tuple();
|
||||
INSERT INTO src VALUES (1, 'ok', 'data');
|
||||
SELECT id, tuple(replaceAll(data, 'a', 'e') AS col_a, type) AS a, tuple(replaceAll(data, 'a', 'e') AS col_b, type) AS b FROM cluster(test_cluster_two_shards, currentDatabase(), src) SETTINGS prefer_localhost_replica=0 FORMAT JSONEachRow;
|
||||
|
||||
DROP TABLE src;
|
||||
|
Loading…
Reference in New Issue
Block a user