2021-09-01 17:59:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
2022-04-03 22:33:59 +00:00
|
|
|
#include <Storages/StorageS3Settings.h>
|
2022-12-16 22:57:09 +00:00
|
|
|
#include <IO/HTTPHeaderEntries.h>
|
2021-09-01 17:59:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-02-01 13:54:03 +00:00
|
|
|
#define EMPTY_SETTINGS(M, ALIAS)
|
|
|
|
DECLARE_SETTINGS_TRAITS(EmptySettingsTraits, EMPTY_SETTINGS)
|
2021-12-27 14:41:37 +00:00
|
|
|
|
|
|
|
struct EmptySettings : public BaseSettings<EmptySettingsTraits> {};
|
|
|
|
|
2021-09-01 17:59:11 +00:00
|
|
|
struct ExternalDataSourceConfiguration
|
|
|
|
{
|
|
|
|
String host;
|
2021-09-02 13:01:26 +00:00
|
|
|
UInt16 port = 0;
|
2022-03-08 14:24:39 +00:00
|
|
|
String username = "default";
|
2021-09-01 17:59:11 +00:00
|
|
|
String password;
|
2022-08-03 19:44:08 +00:00
|
|
|
String quota_key;
|
2021-09-01 17:59:11 +00:00
|
|
|
String database;
|
|
|
|
String table;
|
2021-09-01 23:17:15 +00:00
|
|
|
String schema;
|
2021-09-01 17:59:11 +00:00
|
|
|
|
2021-09-07 11:17:25 +00:00
|
|
|
std::vector<std::pair<String, UInt16>> addresses; /// Failover replicas.
|
2021-10-05 13:02:26 +00:00
|
|
|
String addresses_expr;
|
2021-09-07 11:17:25 +00:00
|
|
|
|
2021-09-01 23:17:15 +00:00
|
|
|
String toString() const;
|
2021-09-15 22:45:43 +00:00
|
|
|
|
|
|
|
void set(const ExternalDataSourceConfiguration & conf);
|
2021-09-01 17:59:11 +00:00
|
|
|
};
|
|
|
|
|
2021-09-01 23:17:15 +00:00
|
|
|
|
2021-10-05 13:02:26 +00:00
|
|
|
using StorageSpecificArgs = std::vector<std::pair<String, ASTPtr>>;
|
2021-09-01 17:59:11 +00:00
|
|
|
|
2021-12-27 14:41:37 +00:00
|
|
|
struct ExternalDataSourceInfo
|
2021-09-22 15:10:25 +00:00
|
|
|
{
|
|
|
|
ExternalDataSourceConfiguration configuration;
|
2021-12-27 14:41:37 +00:00
|
|
|
SettingsChanges settings_changes;
|
2021-09-22 15:10:25 +00:00
|
|
|
};
|
|
|
|
|
2021-12-29 10:02:18 +00:00
|
|
|
using HasConfigKeyFunc = std::function<bool(const String &)>;
|
|
|
|
|
2022-01-10 11:00:03 +00:00
|
|
|
template <typename T = EmptySettingsTraits>
|
|
|
|
std::optional<ExternalDataSourceInfo> getExternalDataSourceConfiguration(
|
2021-12-29 10:02:18 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix,
|
2022-01-10 11:00:03 +00:00
|
|
|
ContextPtr context, HasConfigKeyFunc has_config_key, const BaseSettings<T> & settings = {});
|
2021-09-02 13:01:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// Highest priority is 0, the bigger the number in map, the less the priority.
|
|
|
|
using ExternalDataSourcesConfigurationByPriority = std::map<size_t, std::vector<ExternalDataSourceConfiguration>>;
|
|
|
|
|
|
|
|
struct ExternalDataSourcesByPriority
|
|
|
|
{
|
|
|
|
String database;
|
|
|
|
String table;
|
|
|
|
String schema;
|
|
|
|
ExternalDataSourcesConfigurationByPriority replicas_configurations;
|
|
|
|
};
|
|
|
|
|
|
|
|
ExternalDataSourcesByPriority
|
2021-12-29 10:02:18 +00:00
|
|
|
getExternalDataSourceConfigurationByPriority(const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix, ContextPtr context, HasConfigKeyFunc has_config_key);
|
2021-09-01 17:59:11 +00:00
|
|
|
|
2021-09-07 11:17:25 +00:00
|
|
|
struct URLBasedDataSourceConfiguration
|
|
|
|
{
|
|
|
|
String url;
|
2022-05-27 17:43:34 +00:00
|
|
|
String endpoint;
|
2022-01-12 15:28:13 +00:00
|
|
|
String format = "auto";
|
2021-09-07 11:17:25 +00:00
|
|
|
String compression_method = "auto";
|
2021-12-15 11:30:57 +00:00
|
|
|
String structure = "auto";
|
2021-09-07 11:17:25 +00:00
|
|
|
|
2022-05-27 00:46:26 +00:00
|
|
|
String user;
|
|
|
|
String password;
|
|
|
|
|
2022-12-16 22:57:09 +00:00
|
|
|
HTTPHeaderEntries headers;
|
2021-10-28 12:44:12 +00:00
|
|
|
String http_method;
|
2021-09-15 22:45:43 +00:00
|
|
|
|
|
|
|
void set(const URLBasedDataSourceConfiguration & conf);
|
2021-09-07 11:17:25 +00:00
|
|
|
};
|
|
|
|
|
2021-09-22 15:10:25 +00:00
|
|
|
struct URLBasedDataSourceConfig
|
|
|
|
{
|
|
|
|
URLBasedDataSourceConfiguration configuration;
|
|
|
|
};
|
|
|
|
|
2022-05-27 00:46:26 +00:00
|
|
|
std::optional<URLBasedDataSourceConfig> getURLBasedDataSourceConfiguration(
|
|
|
|
const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix, ContextPtr context);
|
|
|
|
|
2021-09-01 17:59:11 +00:00
|
|
|
}
|