Check once if filter column can be always false in filter transform.

This commit is contained in:
Nikolai Kochetov 2019-12-02 21:33:25 +03:00
parent 9465183408
commit 8524a75580
2 changed files with 15 additions and 2 deletions

View File

@ -64,8 +64,7 @@ FilterTransform::FilterTransform(
IProcessor::Status FilterTransform::prepare()
{
if (constant_filter_description.always_false
|| expression->checkColumnIsAlwaysFalse(filter_column_name))
if (constant_filter_description.always_false)
{
input.close();
output.finish();
@ -84,6 +83,18 @@ void FilterTransform::removeFilterIfNeed(Chunk & chunk)
void FilterTransform::transform(Chunk & chunk)
{
if (!initialized)
{
initialized = true;
if (expression->checkColumnIsAlwaysFalse(filter_column_name))
{
stopReading();
chunk = Chunk(getOutputPort().getHeader().getColumns(), 0);
return;
}
}
size_t num_rows_before_filtration = chunk.getNumRows();
auto columns = chunk.detachColumns();

View File

@ -36,6 +36,8 @@ private:
/// Header after expression, but before removing filter column.
Block transformed_header;
bool initialized = false;
void removeFilterIfNeed(Chunk & chunk);
};