ClickHouse/src/Processors/QueryPlan/OffsetStep.cpp

51 lines
1.3 KiB
C++
Raw Normal View History

2020-06-24 12:09:01 +00:00
#include <Processors/QueryPlan/OffsetStep.h>
2020-06-17 19:38:45 +00:00
#include <Processors/OffsetTransform.h>
2021-10-16 14:03:50 +00:00
#include <QueryPipeline/QueryPipelineBuilder.h>
2020-06-27 14:02:24 +00:00
#include <IO/Operators.h>
#include <Common/JSONBuilder.h>
2020-06-17 19:38:45 +00:00
namespace DB
{
static ITransformingStep::Traits getTraits()
2020-06-18 13:00:16 +00:00
{
return ITransformingStep::Traits
2020-06-18 20:11:42 +00:00
{
{
.preserves_distinct_columns = true,
.returns_single_stream = false,
.preserves_number_of_streams = true,
.preserves_sorting = true,
},
{
.preserves_number_of_rows = false,
}
2020-06-18 13:00:16 +00:00
};
}
2020-06-24 12:09:01 +00:00
OffsetStep::OffsetStep(const DataStream & input_stream_, size_t offset_)
2020-06-18 13:00:16 +00:00
: ITransformingStep(input_stream_, input_stream_.header, getTraits())
2020-06-18 09:22:29 +00:00
, offset(offset_)
2020-06-17 19:38:45 +00:00
{
}
void OffsetStep::transformPipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
2020-06-17 19:38:45 +00:00
{
auto transform = std::make_shared<OffsetTransform>(
pipeline.getHeader(), offset, pipeline.getNumStreams());
2020-06-17 19:38:45 +00:00
2020-08-04 13:06:59 +00:00
pipeline.addTransform(std::move(transform));
2020-06-17 19:38:45 +00:00
}
2020-06-27 14:02:24 +00:00
void OffsetStep::describeActions(FormatSettings & settings) const
2020-06-24 12:09:01 +00:00
{
2020-06-27 14:02:24 +00:00
settings.out << String(settings.offset, ' ') << "Offset " << offset << '\n';
2020-06-24 12:09:01 +00:00
}
void OffsetStep::describeActions(JSONBuilder::JSONMap & map) const
{
map.add("Offset", offset);
}
2020-06-17 19:38:45 +00:00
}