2021-04-14 17:51:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/logger_useful.h>
|
|
|
|
#include <base/shared_ptr_helper.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
|
|
|
*/
|
2021-08-24 19:38:42 +00:00
|
|
|
class StorageExecutable final : public shared_ptr_helper<StorageExecutable>, public IStorage
|
2021-04-14 17:51:55 +00:00
|
|
|
{
|
2021-08-24 19:38:42 +00:00
|
|
|
friend struct shared_ptr_helper<StorageExecutable>;
|
2021-09-03 10:00:40 +00:00
|
|
|
|
2021-04-14 17:51:55 +00:00
|
|
|
public:
|
2021-09-02 11:53:20 +00:00
|
|
|
|
|
|
|
String getName() const override
|
|
|
|
{
|
|
|
|
if (process_pool)
|
|
|
|
return "ExecutablePool";
|
|
|
|
else
|
|
|
|
return "Executable";
|
|
|
|
}
|
2021-04-14 17:51:55 +00:00
|
|
|
|
|
|
|
Pipe read(
|
|
|
|
const Names & column_names,
|
|
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
2021-09-03 10:00:40 +00:00
|
|
|
|
2021-04-14 17:51:55 +00:00
|
|
|
StorageExecutable(
|
|
|
|
const StorageID & table_id,
|
2021-08-25 19:30:22 +00:00
|
|
|
const String & script_name_,
|
2021-08-29 20:19:05 +00:00
|
|
|
const std::vector<String> & arguments_,
|
2021-04-15 21:15:54 +00:00
|
|
|
const String & format_,
|
2021-08-29 20:19:05 +00:00
|
|
|
const std::vector<ASTPtr> & input_queries_,
|
2021-04-14 17:51:55 +00:00
|
|
|
const ColumnsDescription & columns,
|
2021-08-24 19:38:42 +00:00
|
|
|
const ConstraintsDescription & constraints);
|
2021-04-14 17:51:55 +00:00
|
|
|
|
2021-09-02 11:53:20 +00:00
|
|
|
StorageExecutable(
|
|
|
|
const StorageID & table_id,
|
|
|
|
const String & script_name_,
|
|
|
|
const std::vector<String> & arguments_,
|
|
|
|
const String & format_,
|
|
|
|
const std::vector<ASTPtr> & input_queries_,
|
2021-09-09 22:04:52 +00:00
|
|
|
const ExecutableSettings & settings_,
|
2021-09-02 11:53:20 +00:00
|
|
|
const ColumnsDescription & columns,
|
|
|
|
const ConstraintsDescription & constraints);
|
|
|
|
|
2021-04-14 17:51:55 +00:00
|
|
|
private:
|
2021-08-25 19:30:22 +00:00
|
|
|
String script_name;
|
2021-08-29 20:19:05 +00:00
|
|
|
std::vector<String> arguments;
|
2021-04-15 21:15:54 +00:00
|
|
|
String format;
|
2021-08-29 20:19:05 +00:00
|
|
|
std::vector<ASTPtr> input_queries;
|
2021-09-09 22:04:52 +00:00
|
|
|
ExecutableSettings settings;
|
2021-09-02 11:53:20 +00:00
|
|
|
std::shared_ptr<ProcessPool> process_pool;
|
2021-08-24 19:38:42 +00:00
|
|
|
Poco::Logger * log;
|
2021-04-14 17:51:55 +00:00
|
|
|
};
|
|
|
|
|
2021-09-02 11:53:20 +00:00
|
|
|
}
|