mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 13:42:02 +00:00
fixed review, changed tests
This commit is contained in:
parent
d95262622b
commit
e48e6b6a5a
@ -42,7 +42,6 @@ struct QueryPlanOptimizationSettings
|
||||
bool optimize_projection = false;
|
||||
bool force_use_projection = false;
|
||||
String force_projection_name;
|
||||
String preferred_projection_name;
|
||||
bool optimize_use_implicit_projections = false;
|
||||
|
||||
static QueryPlanOptimizationSettings fromSettings(const Settings & from);
|
||||
|
@ -453,21 +453,16 @@ AggregateProjectionCandidates getAggregateProjectionCandidates(
|
||||
{
|
||||
for (const auto & projection : projections)
|
||||
{
|
||||
if (projection.type == ProjectionDescription::Type::Aggregate)
|
||||
if ((projection.type == ProjectionDescription::Type::Aggregate) && (proj_name_from_settings == projection.name))
|
||||
{
|
||||
size_t last_dot_pos = projection.name.find_last_of('.');
|
||||
std::string projection_name = (last_dot_pos != std::string::npos) ? projection.name.substr(last_dot_pos + 1) : projection.name;
|
||||
if (proj_name_from_settings == projection_name)
|
||||
{
|
||||
agg_projections.push_back(&projection);
|
||||
is_projection_found = true;
|
||||
break;
|
||||
}
|
||||
agg_projections.push_back(&projection);
|
||||
is_projection_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_projection_found)
|
||||
throw Exception(ErrorCodes::INCORRECT_DATA, "Projection {} is specified in setting force_optimize_projection_name but not used",
|
||||
proj_name_from_settings);
|
||||
for (const auto & projection : projections)
|
||||
agg_projections.push_back(&projection);
|
||||
}
|
||||
else
|
||||
for (const auto & projection : projections)
|
||||
|
@ -140,17 +140,12 @@ bool optimizeUseNormalProjections(Stack & stack, QueryPlan::Nodes & nodes)
|
||||
{
|
||||
for (const auto * projection : normal_projections)
|
||||
{
|
||||
size_t last_dot_pos = projection->name.find_last_of('.');
|
||||
std::string projection_name = (last_dot_pos != std::string::npos) ? projection->name.substr(last_dot_pos + 1) : projection->name;
|
||||
if (projection_name == proj_name_from_settings)
|
||||
if (projection->name == proj_name_from_settings)
|
||||
{
|
||||
is_projection_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!is_projection_found)
|
||||
throw Exception(ErrorCodes::INCORRECT_DATA, "Projection {} is specified in setting force_optimize_projection_name but not used",
|
||||
proj_name_from_settings);
|
||||
}
|
||||
|
||||
for (const auto * projection : normal_projections)
|
||||
@ -175,12 +170,9 @@ bool optimizeUseNormalProjections(Stack & stack, QueryPlan::Nodes & nodes)
|
||||
if (candidate.sum_marks >= ordinary_reading_marks)
|
||||
continue;
|
||||
|
||||
size_t last_dot_pos = projection->name.find_last_of('.');
|
||||
std::string projection_name = (last_dot_pos != std::string::npos) ? projection->name.substr(last_dot_pos + 1) : projection->name;
|
||||
|
||||
if (!is_projection_found && (best_candidate == nullptr || candidate.sum_marks < best_candidate->sum_marks))
|
||||
best_candidate = &candidate;
|
||||
else if (is_projection_found && projection_name == proj_name_from_settings)
|
||||
else if (is_projection_found && projection->name == proj_name_from_settings)
|
||||
best_candidate = &candidate;
|
||||
}
|
||||
|
||||
|
@ -3,4 +3,5 @@ projection_test_by_string
|
||||
Executing query with setting
|
||||
test
|
||||
projection_test_by_more
|
||||
0
|
||||
test
|
||||
projection_test_by_string
|
||||
|
@ -77,9 +77,15 @@ FROM system.query_log
|
||||
WHERE query_id = '02907_test_1' AND arrayElement(projections, 1) LIKE '%projection_test_by_string'
|
||||
LIMIT 1" | grep -o "projection_test_by_string" || true
|
||||
|
||||
$CLICKHOUSE_CLIENT --query_id '02907_test_1' --preferred_optimize_projection_name 'non_existing_projection' -q "
|
||||
$CLICKHOUSE_CLIENT --query_id '02907_test_2' --preferred_optimize_projection_name 'non_existing_projection' -q "
|
||||
SELECT test_string
|
||||
FROM test
|
||||
WHERE (test_id > 50)
|
||||
AND (test_id < 150)
|
||||
GROUP BY test_string;" 2>&1 | grep -c "BAD_ARGUMENTS" || true
|
||||
GROUP BY test_string;"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "
|
||||
SELECT projections
|
||||
FROM system.query_log
|
||||
WHERE query_id = '02907_test_2' AND arrayElement(projections, 1) LIKE '%projection_test_by_string'
|
||||
LIMIT 1" | grep -o "projection_test_by_string" || true
|
||||
|
Loading…
Reference in New Issue
Block a user