mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
Fix flaky test
This commit is contained in:
parent
e2f4219c12
commit
2e9cdd17ef
@ -2156,19 +2156,31 @@ void QueryAnalyzer::replaceNodesWithPositionalArguments(QueryTreeNodePtr & node_
|
|||||||
node_to_replace = &sort_node->getExpression();
|
node_to_replace = &sort_node->getExpression();
|
||||||
|
|
||||||
auto * constant_node = (*node_to_replace)->as<ConstantNode>();
|
auto * constant_node = (*node_to_replace)->as<ConstantNode>();
|
||||||
if (!constant_node || constant_node->getValue().getType() != Field::Types::UInt64)
|
|
||||||
|
if (!constant_node
|
||||||
|
|| (constant_node->getValue().getType() != Field::Types::UInt64 && constant_node->getValue().getType() != Field::Types::Int64))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
UInt64 positional_argument_number = constant_node->getValue().get<UInt64>();
|
UInt64 pos;
|
||||||
if (positional_argument_number == 0 || positional_argument_number > projection_nodes.size())
|
if (constant_node->getValue().getType() == Field::Types::UInt64)
|
||||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
{
|
||||||
|
pos = constant_node->getValue().get<UInt64>();
|
||||||
|
}
|
||||||
|
else // Int64
|
||||||
|
{
|
||||||
|
auto value = constant_node->getValue().get<Int64>();
|
||||||
|
pos = value > 0 ? value : projection_nodes.size() + value + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pos || pos > projection_nodes.size())
|
||||||
|
throw Exception(
|
||||||
|
ErrorCodes::BAD_ARGUMENTS,
|
||||||
"Positional argument number {} is out of bounds. Expected in range [1, {}]. In scope {}",
|
"Positional argument number {} is out of bounds. Expected in range [1, {}]. In scope {}",
|
||||||
positional_argument_number,
|
pos,
|
||||||
projection_nodes.size(),
|
projection_nodes.size(),
|
||||||
scope.scope_node->formatASTForErrorMessage());
|
scope.scope_node->formatASTForErrorMessage());
|
||||||
|
|
||||||
--positional_argument_number;
|
*node_to_replace = projection_nodes[--pos];
|
||||||
*node_to_replace = projection_nodes[positional_argument_number];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
0 0
|
0 0
|
||||||
4 4
|
|
||||||
3 3
|
|
||||||
2 2
|
|
||||||
5 5
|
|
||||||
1 1
|
1 1
|
||||||
|
2 2
|
||||||
|
3 3
|
||||||
|
4 4
|
||||||
|
5 5
|
||||||
6 6
|
6 6
|
||||||
7 7
|
7 7
|
||||||
9 9
|
|
||||||
8 8
|
8 8
|
||||||
|
9 9
|
||||||
|
45 1
|
||||||
processed 99 0
|
processed 99 0
|
||||||
|
@ -3,7 +3,7 @@ DROP TABLE IF EXISTS t;
|
|||||||
CREATE TABLE t
|
CREATE TABLE t
|
||||||
(
|
(
|
||||||
`n` int,
|
`n` int,
|
||||||
`__unused_group_by_column` int
|
`__unused_group_by_column` int
|
||||||
)
|
)
|
||||||
ENGINE = MergeTree
|
ENGINE = MergeTree
|
||||||
ORDER BY n AS
|
ORDER BY n AS
|
||||||
@ -14,7 +14,9 @@ SELECT
|
|||||||
sum(n),
|
sum(n),
|
||||||
__unused_group_by_column
|
__unused_group_by_column
|
||||||
FROM t
|
FROM t
|
||||||
GROUP BY __unused_group_by_column;
|
GROUP BY __unused_group_by_column ORDER BY __unused_group_by_column;
|
||||||
|
|
||||||
|
SELECT sum(n), 1 as x from t group by x;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'processed' AS type,
|
'processed' AS type,
|
||||||
|
Loading…
Reference in New Issue
Block a user