Fix some tests

This commit is contained in:
Anastasiya Rodigina 2019-05-18 19:46:29 +03:00
parent 6132b57beb
commit b3d811a199
3 changed files with 4 additions and 2 deletions

View File

@ -1496,6 +1496,7 @@ void InterpreterSelectQuery::executeOrder(Pipeline & pipeline, SelectQueryInfo &
// in order to read blocks in fixed order
query_info.do_not_steal_task = true;
query_info.read_in_pk_order = true;
if (order_direction == -1)
{
pipeline.transform([&](auto & stream)
@ -1510,7 +1511,7 @@ void InterpreterSelectQuery::executeOrder(Pipeline & pipeline, SelectQueryInfo &
settings.max_bytes_before_external_sort, context.getTemporaryPath());
};
if (settings.optimize_pk_order && !query.groupBy())
if (settings.optimize_pk_order && !query.groupBy() && !order_descr.empty())
{
if (const auto * merge_tree = dynamic_cast<const MergeTreeData *>(storage.get()))
{

View File

@ -587,7 +587,7 @@ BlockInputStreams MergeTreeDataSelectExecutor::readFromParts(
virt_column_names,
settings);
}
else if (settings.optimize_pk_order)
else if (settings.optimize_pk_order && query_info.read_in_pk_order)
{
std::vector<String> add_columns = data.sorting_key_expr->getRequiredColumns();
column_names_to_read.insert(column_names_to_read.end(), add_columns.begin(), add_columns.end());

View File

@ -54,6 +54,7 @@ struct SelectQueryInfo
/// If set to true, the query from MergeTree will return a set of streams,
/// each of them will read data in sorted by sorting key order.
bool do_not_steal_task = false;
bool read_in_pk_order = false;
/// Prepared sets are used for indices by storage engine.
/// Example: x IN (1, 2, 3)