Fixed tests

This commit is contained in:
Maksim Kita 2023-03-06 10:53:55 +01:00
parent 3d34247998
commit 25088187d4
6 changed files with 66 additions and 42 deletions

View File

@ -4608,25 +4608,47 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
auto if_function_condition = if_function_arguments[0]; auto if_function_condition = if_function_arguments[0];
resolveExpressionNode(if_function_condition, scope, false /*allow_lambda_expression*/, false /*allow_table_expression*/); resolveExpressionNode(if_function_condition, scope, false /*allow_lambda_expression*/, false /*allow_table_expression*/);
QueryTreeNodePtr constant_if_result_node;
auto constant_condition = tryExtractConstantFromConditionNode(if_function_condition); auto constant_condition = tryExtractConstantFromConditionNode(if_function_condition);
if (constant_condition.has_value() && if_function_arguments.size() == 3) if (constant_condition.has_value() && if_function_arguments.size() == 3)
{ {
if (*constant_condition) QueryTreeNodePtr constant_if_result_node;
constant_if_result_node = if_function_arguments[1]; QueryTreeNodePtr possibly_invalid_argument_node;
else
constant_if_result_node = if_function_arguments[2];
}
if (constant_if_result_node) if (*constant_condition)
{ {
auto result_projection_names = resolveExpressionNode(constant_if_result_node, possibly_invalid_argument_node = if_function_arguments[2];
scope, constant_if_result_node = if_function_arguments[1];
false /*allow_lambda_expression*/, }
false /*allow_table_expression*/); else
node = std::move(constant_if_result_node); {
return result_projection_names; possibly_invalid_argument_node = if_function_arguments[1];
constant_if_result_node = if_function_arguments[2];
}
bool apply_constant_if_optimization = false;
try
{
resolveExpressionNode(possibly_invalid_argument_node,
scope,
false /*allow_lambda_expression*/,
false /*allow_table_expression*/);
}
catch (...)
{
apply_constant_if_optimization = true;
}
if (apply_constant_if_optimization)
{
auto result_projection_names = resolveExpressionNode(constant_if_result_node,
scope,
false /*allow_lambda_expression*/,
false /*allow_table_expression*/);
node = std::move(constant_if_result_node);
return result_projection_names;
}
} }
} }

View File

@ -1193,6 +1193,7 @@ JoinTreeQueryPlan buildJoinTreeQueryPlan(const QueryTreeNodePtr & query_node,
if (table_expression == left_table_expression) if (table_expression == left_table_expression)
{ {
query_plans_stack.push_back(std::move(left_table_expression_query_plan)); query_plans_stack.push_back(std::move(left_table_expression_query_plan));
left_table_expression = {};
continue; continue;
} }

View File

@ -5,6 +5,6 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CUR_DIR"/../shell_config.sh . "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(NULL)" 2>&1 | grep -q "ILLEGAL_COLUMN" && echo "OK" || echo "FAIL" $CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(NULL)" 2>&1 | grep -q "ILLEGAL_COLUMN" && echo "OK" || echo "FAIL"
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL)) SETTINGS allow_experimental_analyzer = 1" 2>&1 | grep -q "ILLEGAL_COLUMN" && echo "OK" || echo "FAIL" $CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL))" 2>&1 | grep -q "ILLEGAL_TYPE_OF_ARGUMENT" && echo "OK" || echo "FAIL"
$CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL)) from numbers(10) SETTINGS allow_experimental_analyzer = 1" 2>&1 | grep -q "ILLEGAL_COLUMN" && echo "OK" || echo "FAIL" $CLICKHOUSE_LOCAL -q "SELECT assumeNotNull(materialize(NULL)) from numbers(10)" 2>&1 | grep -q "ILLEGAL_TYPE_OF_ARGUMENT" && echo "OK" || echo "FAIL"

View File

@ -4,19 +4,19 @@
2022-09-09 12:00:00 0x 2022-09-09 12:00:00 0x
2022-09-09 12:00:00 1 2022-09-09 12:00:00 1
2022-09-09 12:00:00 1x 2022-09-09 12:00:00 1x
Prefix sort description: toStartOfMinute(test.t_order_by_monotonic.t_0) ASC Prefix sort description: toStartOfMinute(test.t_0) ASC
Result sort description: toStartOfMinute(test.t_order_by_monotonic.t_0) ASC, test.t_order_by_monotonic.c1_1 ASC Result sort description: toStartOfMinute(test.t_0) ASC, test.c1_1 ASC
Prefix sort description: toStartOfMinute(test.t_order_by_monotonic.t_0) ASC Prefix sort description: toStartOfMinute(test.t_0) ASC
Result sort description: toStartOfMinute(test.t_order_by_monotonic.t_0) ASC Result sort description: toStartOfMinute(test.t_0) ASC
Prefix sort description: negate(test.t_order_by_monotonic.a_0) ASC Prefix sort description: negate(test.a_0) ASC
Result sort description: negate(test.t_order_by_monotonic.a_0) ASC Result sort description: negate(test.a_0) ASC
Prefix sort description: negate(test.t_order_by_monotonic.a_0) ASC, negate(test.t_order_by_monotonic.b_1) ASC Prefix sort description: negate(test.a_0) ASC, negate(test.b_1) ASC
Result sort description: negate(test.t_order_by_monotonic.a_0) ASC, negate(test.t_order_by_monotonic.b_1) ASC Result sort description: negate(test.a_0) ASC, negate(test.b_1) ASC
Prefix sort description: test.t_order_by_monotonic.a_0 DESC, negate(test.t_order_by_monotonic.b_1) ASC Prefix sort description: test.a_0 DESC, negate(test.b_1) ASC
Result sort description: test.t_order_by_monotonic.a_0 DESC, negate(test.t_order_by_monotonic.b_1) ASC Result sort description: test.a_0 DESC, negate(test.b_1) ASC
Prefix sort description: negate(test.t_order_by_monotonic.a_0) ASC, test.t_order_by_monotonic.b_1 DESC Prefix sort description: negate(test.a_0) ASC, test.b_1 DESC
Result sort description: negate(test.t_order_by_monotonic.a_0) ASC, test.t_order_by_monotonic.b_1 DESC Result sort description: negate(test.a_0) ASC, test.b_1 DESC
Prefix sort description: negate(test.t_order_by_monotonic.a_0) ASC Prefix sort description: negate(test.a_0) ASC
Result sort description: negate(test.t_order_by_monotonic.a_0) ASC, test.t_order_by_monotonic.b_1 ASC Result sort description: negate(test.a_0) ASC, test.b_1 ASC
Prefix sort description: test.t_order_by_monotonic.a_0 ASC Prefix sort description: test.a_0 ASC
Result sort description: test.t_order_by_monotonic.a_0 ASC, negate(test.t_order_by_monotonic.b_1) ASC Result sort description: test.a_0 ASC, negate(test.b_1) ASC

View File

@ -17,12 +17,12 @@ $CLICKHOUSE_CLIENT -q "CREATE TABLE t_order_by_monotonic (t DateTime, c1 String)
SELECT '2022-09-09 12:00:30', toString(number % 2)|| 'x' FROM numbers(3)" SELECT '2022-09-09 12:00:30', toString(number % 2)|| 'x' FROM numbers(3)"
$CLICKHOUSE_CLIENT --optimize_aggregation_in_order=1 -q "SELECT count() FROM $CLICKHOUSE_CLIENT --optimize_aggregation_in_order=1 -q "SELECT count() FROM
(SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic GROUP BY s, c1)" (SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic AS test GROUP BY s, c1)"
$CLICKHOUSE_CLIENT --optimize_read_in_order=1 -q "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic ORDER BY s, c1" $CLICKHOUSE_CLIENT --optimize_read_in_order=1 -q "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic AS test ORDER BY s, c1"
explain_sort_description "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic ORDER BY s, c1" explain_sort_description "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic AS test ORDER BY s, c1"
explain_sort_description "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic ORDER BY s" explain_sort_description "SELECT toStartOfMinute(t) AS s, c1 FROM t_order_by_monotonic AS test ORDER BY s"
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t_order_by_monotonic" $CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t_order_by_monotonic"
@ -30,11 +30,11 @@ $CLICKHOUSE_CLIENT -q "CREATE TABLE t_order_by_monotonic (a Int64, b Int64) ENGI
$CLICKHOUSE_CLIENT -q "INSERT INTO t_order_by_monotonic VALUES (1, 1) (1, 2), (2, 1) (2, 2)" $CLICKHOUSE_CLIENT -q "INSERT INTO t_order_by_monotonic VALUES (1, 1) (1, 2), (2, 1) (2, 2)"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY -a" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY -a"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY -a, -b" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY -a, -b"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY a DESC, -b" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY a DESC, -b"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY -a, b DESC" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY -a, b DESC"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY -a, b" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY -a, b"
explain_sort_description "SELECT * FROM t_order_by_monotonic ORDER BY a, -b" explain_sort_description "SELECT * FROM t_order_by_monotonic AS test ORDER BY a, -b"
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t_order_by_monotonic" $CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS t_order_by_monotonic"

View File

@ -1,4 +1,5 @@
-- { echoOn } -- { echoOn }
SELECT SELECT
cutURLParameter('http://bigmir.net/?a=b&c=d', []), cutURLParameter('http://bigmir.net/?a=b&c=d', []),
cutURLParameter('http://bigmir.net/?a=b&c=d', ['a']), cutURLParameter('http://bigmir.net/?a=b&c=d', ['a']),