提交 be7c70da 编写于 作者: A artpaul

fix IN with nested tuples [#CLICKHOUSE-1999]

上级 e7ee6dfd
......@@ -100,12 +100,18 @@ bool Set::insertFromBlock(const Block & block, bool create_ordered_set)
materialized_columns.emplace_back(converted);
key_columns.back() = materialized_columns.back().get();
}
}
/** Flatten tuples. For case when written
* (a, b) IN (SELECT (a, b) FROM table)
* instead of more typical
* (a, b) IN (SELECT a, b FROM table)
*/
/** Flatten tuples. For case when written
* (a, b) IN (SELECT (a, b) FROM table)
* instead of more typical
* (a, b) IN (SELECT a, b FROM table)
*
* Avoid flatten in case then we have more than one column:
* Ex.: 1, (2, 3) become just 1, 2, 3
*/
if (keys_size == 1)
{
if (const ColumnTuple * tuple = typeid_cast<const ColumnTuple *>(key_columns.back()))
{
key_columns.pop_back();
......@@ -229,7 +235,7 @@ void Set::createFromAST(const DataTypes & types, ASTPtr node, const Context & co
if (value.isNull())
break;
tuple_values[j] = value; /// TODO Сделать move семантику для Field.
tuple_values[j] = value;
}
if (j == tuple_size)
......
......@@ -25,3 +25,8 @@
1
0
1
1 (2,3)
2 (2,3)
3 (2,3)
4 (2,3)
5 (2,3)
......@@ -19,3 +19,8 @@ SELECT ['Hello', 'world'] IN ('world');
SELECT ['Hello', 'world'] NOT IN ('world');
SELECT ['Hello', 'world'] NOT IN ('Hello', 'world');
SELECT ['Hello', 'world'] NOT IN ('hello', 'world');
SELECT number, tuple FROM (SELECT 1 AS number, (2, 3) AS tuple) WHERE (number, tuple) IN (((1, (2, 3)), (4, (5, 6))));
SELECT number, tuple FROM (SELECT 2 AS number, (2, 3) AS tuple) WHERE (number, tuple) IN ((2, (2, 3)));
SELECT number, tuple FROM (SELECT 3 AS number, (2, 3) AS tuple) WHERE (number, tuple) IN (3, (2, 3));
SELECT number, tuple FROM (SELECT 4 AS number, (2, 3) AS tuple) WHERE (number, tuple) IN (SELECT (4, (2, 3)));
SELECT number, tuple FROM (SELECT 5 AS number, (2, 3) AS tuple) WHERE (number, tuple) IN (SELECT 5, (2, 3));
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册