2021-04-14 17:51:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-04-27 15:05:45 +00:00
|
|
|
#include <Common/logger_useful.h>
|
2021-04-14 17:51:55 +00:00
|
|
|
#include <Storages/IStorage.h>
|
2021-10-15 20:18:20 +00:00
|
|
|
#include <Processors/Sources/ShellCommandSource.h>
|
2021-09-09 22:04:52 +00:00
|
|
|
#include <Storages/ExecutableSettings.h>
|
2021-08-24 19:38:42 +00:00
|
|
|
|
2021-04-14 17:51:55 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-09-02 11:53:20 +00:00
|
|
|
|
2021-04-14 17:51:55 +00:00
|
|
|
/**
|
|
|
|
* This class represents table engine for external executable files.
|
2021-09-02 11:53:20 +00:00
|
|
|
* Executable storage that will start process for read.
|
|
|
|
* ExecutablePool storage maintain pool of processes and take process from pool for read.
|
2021-04-14 17:51:55 +00:00
|
|
|
*/
|
2022-05-03 06:43:28 +00:00
|
|
|
class StorageExecutable final : public IStorage
|
2021-04-14 17:51:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-04-19 20:47:29 +00:00
|
|
|
StorageExecutable(
|
|
|
|
const StorageID & table_id,
|
|
|
|
const String & format,
|
|
|
|
const ExecutableSettings & settings,
|
|
|
|
const std::vector<ASTPtr> & input_queries,
|
|
|
|
const ColumnsDescription & columns,
|
|
|
|
const ConstraintsDescription & constraints);
|
2021-09-02 11:53:20 +00:00
|
|
|
|
|
|
|
String getName() const override
|
|
|
|
{
|
2021-12-28 09:43:30 +00:00
|
|
|
if (settings.is_executable_pool)
|
2021-09-02 11:53:20 +00:00
|
|
|
return "ExecutablePool";
|
|
|
|
else
|
|
|
|
return "Executable";
|
|
|
|
}
|
2021-04-14 17:51:55 +00:00
|
|
|
|
2022-05-23 19:47:32 +00:00
|
|
|
void read(
|
|
|
|
QueryPlan & query_plan,
|
2021-04-14 17:51:55 +00:00
|
|
|
const Names & column_names,
|
2021-09-09 11:27:10 +00:00
|
|
|
const StorageSnapshotPtr & /*storage_snapshot*/,
|
2021-04-14 17:51:55 +00:00
|
|
|
SelectQueryInfo & query_info,
|
2021-08-24 19:38:42 +00:00
|
|
|
ContextPtr context,
|
2021-04-14 17:51:55 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
|
|
|
size_t max_block_size,
|
2021-08-24 19:38:42 +00:00
|
|
|
unsigned threads) override;
|
2021-04-14 17:51:55 +00:00
|
|
|
|
|
|
|
private:
|
2021-09-09 22:04:52 +00:00
|
|
|
ExecutableSettings settings;
|
2021-11-01 11:22:21 +00:00
|
|
|
std::vector<ASTPtr> input_queries;
|
2021-08-24 19:38:42 +00:00
|
|
|
Poco::Logger * log;
|
2021-12-28 09:43:30 +00:00
|
|
|
std::unique_ptr<ShellCommandSourceCoordinator> coordinator;
|
2021-04-14 17:51:55 +00:00
|
|
|
};
|
|
|
|
|
2021-09-02 11:53:20 +00:00
|
|
|
}
|