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>
|
2021-04-16 16:36:59 +00:00
|
|
|
#include <Common/JSONBuilder.h>
|
2020-06-17 19:38:45 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-07-28 13:10:48 +00:00
|
|
|
static ITransformingStep::Traits getTraits()
|
2020-06-18 13:00:16 +00:00
|
|
|
{
|
2020-07-28 13:10:48 +00:00
|
|
|
return ITransformingStep::Traits
|
2020-06-18 20:11:42 +00:00
|
|
|
{
|
2020-07-28 13:10:48 +00:00
|
|
|
{
|
2020-06-22 10:18:28 +00:00
|
|
|
.preserves_distinct_columns = true,
|
|
|
|
.returns_single_stream = false,
|
|
|
|
.preserves_number_of_streams = true,
|
2020-07-27 15:37:43 +00:00
|
|
|
.preserves_sorting = true,
|
2020-07-28 13:10:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-09-14 16:28:41 +00:00
|
|
|
void OffsetStep::transformPipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
|
2020-06-17 19:38:45 +00:00
|
|
|
{
|
2020-06-22 10:18:28 +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
|
|
|
}
|
|
|
|
|
2021-04-16 16:36:59 +00:00
|
|
|
void OffsetStep::describeActions(JSONBuilder::JSONMap & map) const
|
|
|
|
{
|
|
|
|
map.add("Offset", offset);
|
|
|
|
}
|
|
|
|
|
2020-06-17 19:38:45 +00:00
|
|
|
}
|