diff options
author | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 09:58:56 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@ydb.tech> | 2023-11-14 10:20:20 +0300 |
commit | c2b2dfd9827a400a8495e172a56343462e3ceb82 (patch) | |
tree | cd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h | |
parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
download | ydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h')
-rw-r--r-- | contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h b/contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h new file mode 100644 index 0000000000..d4e737a7de --- /dev/null +++ b/contrib/clickhouse/src/Storages/ExternalDataSourceConfiguration.h @@ -0,0 +1,92 @@ +#pragma once + +#include <Interpreters/Context.h> +#include <Poco/Util/AbstractConfiguration.h> +#include <Storages/StorageS3Settings.h> +#include <IO/HTTPHeaderEntries.h> + + +namespace DB +{ + +#define EMPTY_SETTINGS(M, ALIAS) +DECLARE_SETTINGS_TRAITS(EmptySettingsTraits, EMPTY_SETTINGS) + +struct EmptySettings : public BaseSettings<EmptySettingsTraits> {}; + +struct ExternalDataSourceConfiguration +{ + String host; + UInt16 port = 0; + String username = "default"; + String password; + String quota_key; + String database; + String table; + String schema; + + std::vector<std::pair<String, UInt16>> addresses; /// Failover replicas. + String addresses_expr; + + String toString() const; + + void set(const ExternalDataSourceConfiguration & conf); +}; + + +using StorageSpecificArgs = std::vector<std::pair<String, ASTPtr>>; + +struct ExternalDataSourceInfo +{ + ExternalDataSourceConfiguration configuration; + SettingsChanges settings_changes; +}; + +using HasConfigKeyFunc = std::function<bool(const String &)>; + +template <typename T = EmptySettingsTraits> +std::optional<ExternalDataSourceInfo> getExternalDataSourceConfiguration( + const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix, + ContextPtr context, HasConfigKeyFunc has_config_key, const BaseSettings<T> & settings = {}); + + +/// 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 +getExternalDataSourceConfigurationByPriority(const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix, ContextPtr context, HasConfigKeyFunc has_config_key); + +struct URLBasedDataSourceConfiguration +{ + String url; + String endpoint; + String format = "auto"; + String compression_method = "auto"; + String structure = "auto"; + + String user; + String password; + + HTTPHeaderEntries headers; + String http_method; + + void set(const URLBasedDataSourceConfiguration & conf); +}; + +struct URLBasedDataSourceConfig +{ + URLBasedDataSourceConfiguration configuration; +}; + +std::optional<URLBasedDataSourceConfig> getURLBasedDataSourceConfiguration( + const Poco::Util::AbstractConfiguration & dict_config, const String & dict_config_prefix, ContextPtr context); + +} |