mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
88a9b7de91
don't use copyData because it calls writeSuffix() prematurely.
77 lines
1.7 KiB
C++
77 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <DataStreams/copyData.h>
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
#include <DataStreams/OneBlockInputStream.h>
|
|
#include <DataStreams/MaterializingBlockInputStream.h>
|
|
#include <Storages/StorageMaterializedView.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ReplicatedMergeTreeBlockOutputStream;
|
|
|
|
|
|
/** Writes data to the specified table and to all dependent materialized views.
|
|
*/
|
|
class PushingToViewsBlockOutputStream : public IBlockOutputStream
|
|
{
|
|
public:
|
|
PushingToViewsBlockOutputStream(
|
|
const String & database, const String & table, const StoragePtr & storage,
|
|
const Context & context_, const ASTPtr & query_ptr_, bool no_destination = false);
|
|
|
|
Block getHeader() const override { return storage->getSampleBlock(); }
|
|
void write(const Block & block) override;
|
|
|
|
void flush() override
|
|
{
|
|
if (output)
|
|
output->flush();
|
|
|
|
for (auto & view : views)
|
|
view.out->flush();
|
|
}
|
|
|
|
void writePrefix() override
|
|
{
|
|
if (output)
|
|
output->writePrefix();
|
|
|
|
for (auto & view : views)
|
|
view.out->writePrefix();
|
|
}
|
|
|
|
void writeSuffix() override
|
|
{
|
|
if (output)
|
|
output->writeSuffix();
|
|
|
|
for (auto & view : views)
|
|
view.out->writeSuffix();
|
|
}
|
|
|
|
private:
|
|
StoragePtr storage;
|
|
BlockOutputStreamPtr output;
|
|
ReplicatedMergeTreeBlockOutputStream * replicated_output = nullptr;
|
|
|
|
const Context & context;
|
|
ASTPtr query_ptr;
|
|
|
|
struct ViewInfo
|
|
{
|
|
ASTPtr query;
|
|
String database;
|
|
String table;
|
|
BlockOutputStreamPtr out;
|
|
};
|
|
|
|
std::vector<ViewInfo> views;
|
|
std::unique_ptr<Context> views_context;
|
|
};
|
|
|
|
|
|
}
|