mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
some tests + ability to echo the queries
This commit is contained in:
parent
fc426807a8
commit
157fe3e8b4
@ -949,6 +949,11 @@ private:
|
||||
TestHint test_hint(test_mode, all_queries_text);
|
||||
if (test_hint.clientError() || test_hint.serverError())
|
||||
processTextAsSingleQuery("SET send_logs_level = 'none'");
|
||||
|
||||
// Echo all queries if asked; makes for a more readable reference
|
||||
// file.
|
||||
if (test_hint.echoQueries())
|
||||
echo_queries = true;
|
||||
}
|
||||
|
||||
/// Several queries separated by ';'.
|
||||
|
@ -19,6 +19,7 @@ namespace ErrorCodes
|
||||
|
||||
/// Checks expected server and client error codes in testmode.
|
||||
/// To enable it add special comment after the query: "-- { serverError 60 }" or "-- { clientError 20 }".
|
||||
/// Also you can enable echoing all queries by writing "-- { echo }".
|
||||
class TestHint
|
||||
{
|
||||
public:
|
||||
@ -84,12 +85,14 @@ public:
|
||||
|
||||
int serverError() const { return server_error; }
|
||||
int clientError() const { return client_error; }
|
||||
bool echoQueries() const { return echo; }
|
||||
|
||||
private:
|
||||
bool enabled = false;
|
||||
const String & query;
|
||||
int server_error = 0;
|
||||
int client_error = 0;
|
||||
bool echo = false;
|
||||
|
||||
void parse(const String & hint)
|
||||
{
|
||||
@ -107,6 +110,8 @@ private:
|
||||
ss >> server_error;
|
||||
else if (item == "clientError")
|
||||
ss >> client_error;
|
||||
else if (item == "echo")
|
||||
echo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,8 +474,6 @@ bool ExpressionAnalyzer::makeWindowDescriptions(ActionsDAGPtr & actions)
|
||||
{
|
||||
for (const ASTFunction * function_node : windowFunctions())
|
||||
{
|
||||
fmt::print(stderr, "window function ast: {}\n", function_node->dumpTree());
|
||||
|
||||
assert(function_node->is_window_function);
|
||||
|
||||
// FIXME not thread-safe, should use a per-query counter.
|
||||
|
@ -396,8 +396,6 @@ bool ParserFunction::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
fmt::print(stderr, "window function ast {}\n", function_node->dumpTree());
|
||||
}
|
||||
|
||||
node = function_node;
|
||||
|
92
tests/queries/0_stateless/01591_window_functions.reference
Normal file
92
tests/queries/0_stateless/01591_window_functions.reference
Normal file
@ -0,0 +1,92 @@
|
||||
select number, count() over (partition by intDiv(number, 3) order by number) from numbers(10);
|
||||
|
||||
-- proper calculation across blocks
|
||||
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 1
|
||||
4 2
|
||||
5 3
|
||||
6 1
|
||||
7 2
|
||||
8 3
|
||||
9 1
|
||||
select number, max(number) over (partition by intDiv(number, 3) order by number desc) from numbers(10) settings max_block_size = 2;
|
||||
|
||||
-- not a window function
|
||||
|
||||
2 2
|
||||
1 2
|
||||
0 2
|
||||
5 5
|
||||
4 5
|
||||
3 5
|
||||
8 8
|
||||
7 8
|
||||
6 8
|
||||
9 9
|
||||
select number, abs(number) over (partition by toString(intDiv(number, 3))) from numbers(10); -- { serverError 63 }
|
||||
|
||||
-- no partition by
|
||||
|
||||
select number, avg(number) over (order by number) from numbers(10);
|
||||
|
||||
-- no order by
|
||||
|
||||
0 0
|
||||
1 0
|
||||
2 1
|
||||
3 1
|
||||
4 2
|
||||
5 2
|
||||
6 3
|
||||
7 3
|
||||
8 4
|
||||
9 4
|
||||
select number, quantileExact(number) over (partition by intDiv(number, 3)) from numbers(10);
|
||||
|
||||
-- can add an alias after window spec
|
||||
|
||||
0 0
|
||||
1 1
|
||||
2 1
|
||||
3 3
|
||||
4 4
|
||||
5 4
|
||||
6 6
|
||||
7 7
|
||||
8 7
|
||||
9 9
|
||||
select number, quantileExact(number) over (partition by intDiv(number, 3)) q from numbers(10);
|
||||
|
||||
-- can't reference it yet -- the window functions are calculated at the
|
||||
-- last stage of select, after all other functions.
|
||||
|
||||
0 0
|
||||
1 1
|
||||
2 1
|
||||
3 3
|
||||
4 4
|
||||
5 4
|
||||
6 6
|
||||
7 7
|
||||
8 7
|
||||
9 9
|
||||
select q * 10, quantileExact(number) over (partition by intDiv(number, 3)) q from numbers(10); -- { serverError 47 }
|
||||
|
||||
-- should work in ORDER BY though
|
||||
|
||||
select number, max(number) over (partition by intDiv(number, 3) order by number desc) m from numbers(10) order by m desc, number;
|
||||
|
||||
|
||||
9 9
|
||||
6 8
|
||||
7 8
|
||||
8 8
|
||||
3 5
|
||||
4 5
|
||||
5 5
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
27
tests/queries/0_stateless/01591_window_functions.sql
Normal file
27
tests/queries/0_stateless/01591_window_functions.sql
Normal file
@ -0,0 +1,27 @@
|
||||
-- { echo }
|
||||
|
||||
-- just something basic
|
||||
select number, count() over (partition by intDiv(number, 3) order by number) from numbers(10);
|
||||
|
||||
-- proper calculation across blocks
|
||||
select number, max(number) over (partition by intDiv(number, 3) order by number desc) from numbers(10) settings max_block_size = 2;
|
||||
|
||||
-- not a window function
|
||||
select number, abs(number) over (partition by toString(intDiv(number, 3))) from numbers(10); -- { serverError 63 }
|
||||
|
||||
-- no partition by
|
||||
select number, avg(number) over (order by number) from numbers(10);
|
||||
|
||||
-- no order by
|
||||
select number, quantileExact(number) over (partition by intDiv(number, 3)) from numbers(10);
|
||||
|
||||
-- can add an alias after window spec
|
||||
select number, quantileExact(number) over (partition by intDiv(number, 3)) q from numbers(10);
|
||||
|
||||
-- can't reference it yet -- the window functions are calculated at the
|
||||
-- last stage of select, after all other functions.
|
||||
select q * 10, quantileExact(number) over (partition by intDiv(number, 3)) q from numbers(10); -- { serverError 47 }
|
||||
|
||||
-- should work in ORDER BY though
|
||||
select number, max(number) over (partition by intDiv(number, 3) order by number desc) m from numbers(10) order by m desc, number;
|
||||
|
Loading…
Reference in New Issue
Block a user