ClickHouse/dbms/src/Interpreters/SelectQueryOptions.h

85 lines
2.1 KiB
C++
Raw Normal View History

#pragma once
#include <Core/QueryProcessingStage.h>
namespace DB
{
/**
* to_stage
* - the stage to which the query is to be executed. By default - till to the end.
* You can perform till the intermediate aggregation state, which are combined from different servers for distributed query processing.
*
* subquery_depth
* - to control the limit on the depth of nesting of subqueries. For subqueries, a value that is incremented by one is passed;
* for INSERT SELECT, a value 1 is passed instead of 0.
*
* only_analyze
* - the object was created only for query analysis.
2019-03-15 15:57:18 +00:00
*
* is_subquery
* - there could be some specific for subqueries. Ex. there's no need to pass duplicated columns in results, cause of indirect results.
*/
2019-03-18 12:05:51 +00:00
struct SelectQueryOptions
{
2019-03-18 12:05:51 +00:00
QueryProcessingStage::Enum to_stage;
size_t subquery_depth;
bool only_analyze;
bool modify_inplace;
2019-03-18 14:56:33 +00:00
bool remove_duplicates;
bool ignore_limits;
2019-03-18 12:05:51 +00:00
2019-03-15 15:57:18 +00:00
SelectQueryOptions(QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, size_t depth = 0)
: to_stage(stage)
, subquery_depth(depth)
, only_analyze(false)
, modify_inplace(false)
2019-03-18 14:56:33 +00:00
, remove_duplicates(false)
2019-06-17 22:07:16 +00:00
, ignore_limits(false)
2019-03-15 15:57:18 +00:00
{}
2019-03-18 12:05:51 +00:00
SelectQueryOptions copy() const { return *this; }
2019-03-18 12:05:51 +00:00
SelectQueryOptions subquery() const
{
2019-03-15 15:57:18 +00:00
SelectQueryOptions out = *this;
2019-03-18 12:05:51 +00:00
out.to_stage = QueryProcessingStage::Complete;
2019-03-15 15:57:18 +00:00
++out.subquery_depth;
return out;
}
2019-03-18 12:05:51 +00:00
SelectQueryOptions & analyze(bool value = true)
{
2019-03-18 12:05:51 +00:00
only_analyze = value;
return *this;
}
2019-03-18 12:05:51 +00:00
SelectQueryOptions & modify(bool value = true)
{
2019-03-18 12:05:51 +00:00
modify_inplace = value;
return *this;
}
2019-03-18 12:05:51 +00:00
SelectQueryOptions & noModify() { return modify(false); }
2019-03-18 14:56:33 +00:00
SelectQueryOptions & removeDuplicates(bool value = true)
{
remove_duplicates = value;
return *this;
}
2019-03-18 12:05:51 +00:00
SelectQueryOptions & noSubquery()
{
2019-03-18 12:05:51 +00:00
subquery_depth = 0;
return *this;
}
SelectQueryOptions & ignoreLimits(bool value = true)
{
ignore_limits = value;
return *this;
}
};
}