mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-15 12:14:18 +00:00
Avoid reusing columns among different named tuples
This commit is contained in:
parent
9ae3d85dfe
commit
1c6e7d1ab3
@ -182,6 +182,30 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
/// Function "tuple" which generates named tuple should use argument aliases to construct its name.
|
||||
if (function_node.getFunctionName() == "tuple")
|
||||
{
|
||||
if (const DataTypeTuple * type_tuple = typeid_cast<const DataTypeTuple *>(function_node.getResultType().get()))
|
||||
{
|
||||
if (type_tuple->haveExplicitNames())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String in_function_second_argument_node_name;
|
||||
|
||||
if (isNameOfInFunction(function_node.getFunctionName()))
|
||||
|
@ -0,0 +1 @@
|
||||
1 ('dete','ok') ('dete','ok')
|
@ -0,0 +1,12 @@
|
||||
DROP TABLE IF EXISTS src;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
|
||||
CREATE TABLE src (id UInt32, type String, data String) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE dst (id UInt32, a Tuple (col_a Nullable(String), type String), b Tuple (col_b Nullable(String), type String)) ENGINE = MergeTree ORDER BY id;
|
||||
|
||||
INSERT INTO src VALUES (1, 'ok', 'data');
|
||||
INSERT INTO dst (id, a, b) 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 src;
|
||||
SELECT * FROM dst;
|
||||
|
||||
DROP TABLE src;
|
||||
DROP TABLE dst;
|
Loading…
Reference in New Issue
Block a user