mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #15008 from ClickHouse/clang-tidy-11-without-enabling
Fix terribly wrong code
This commit is contained in:
commit
1474b80ecc
@ -3,12 +3,11 @@
|
|||||||
#if WITH_COVERAGE
|
#if WITH_COVERAGE
|
||||||
|
|
||||||
# include <mutex>
|
# include <mutex>
|
||||||
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
# if defined(__clang__)
|
# if defined(__clang__)
|
||||||
extern "C" void __llvm_profile_dump();
|
extern "C" void __llvm_profile_dump(); // NOLINT
|
||||||
# elif defined(__GNUC__) || defined(__GNUG__)
|
# elif defined(__GNUC__) || defined(__GNUG__)
|
||||||
extern "C" void __gcov_exit();
|
extern "C" void __gcov_exit();
|
||||||
# endif
|
# endif
|
||||||
@ -23,7 +22,7 @@ void dumpCoverageReportIfPossible()
|
|||||||
std::lock_guard lock(mutex);
|
std::lock_guard lock(mutex);
|
||||||
|
|
||||||
# if defined(__clang__)
|
# if defined(__clang__)
|
||||||
__llvm_profile_dump();
|
__llvm_profile_dump(); // NOLINT
|
||||||
# elif defined(__GNUC__) || defined(__GNUG__)
|
# elif defined(__GNUC__) || defined(__GNUG__)
|
||||||
__gcov_exit();
|
__gcov_exit();
|
||||||
# endif
|
# endif
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# pragma clang diagnostic ignored "-Wunused-macros"
|
# pragma clang diagnostic ignored "-Wunused-macros"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __msan_unpoison(X, Y)
|
#define __msan_unpoison(X, Y) // NOLINT
|
||||||
#if defined(__has_feature)
|
#if defined(__has_feature)
|
||||||
# if __has_feature(memory_sanitizer)
|
# if __has_feature(memory_sanitizer)
|
||||||
# undef __msan_unpoison
|
# undef __msan_unpoison
|
||||||
@ -84,7 +84,7 @@ extern "C"
|
|||||||
#ifdef ADDRESS_SANITIZER
|
#ifdef ADDRESS_SANITIZER
|
||||||
void __lsan_ignore_object(const void *);
|
void __lsan_ignore_object(const void *);
|
||||||
#else
|
#else
|
||||||
void __lsan_ignore_object(const void *) {}
|
void __lsan_ignore_object(const void *) {} // NOLINT
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include <Interpreters/loadMetadata.h>
|
#include <Interpreters/loadMetadata.h>
|
||||||
#include <Interpreters/DatabaseCatalog.h>
|
#include <Interpreters/DatabaseCatalog.h>
|
||||||
#include <Interpreters/DNSCacheUpdater.h>
|
#include <Interpreters/DNSCacheUpdater.h>
|
||||||
#include <Interpreters/SystemLog.cpp>
|
|
||||||
#include <Interpreters/ExternalLoaderXMLConfigRepository.h>
|
#include <Interpreters/ExternalLoaderXMLConfigRepository.h>
|
||||||
#include <Access/AccessControlManager.h>
|
#include <Access/AccessControlManager.h>
|
||||||
#include <Storages/StorageReplicatedMergeTree.h>
|
#include <Storages/StorageReplicatedMergeTree.h>
|
||||||
|
@ -67,6 +67,7 @@ set(dbms_sources)
|
|||||||
add_headers_and_sources(clickhouse_common_io Common)
|
add_headers_and_sources(clickhouse_common_io Common)
|
||||||
add_headers_and_sources(clickhouse_common_io Common/HashTable)
|
add_headers_and_sources(clickhouse_common_io Common/HashTable)
|
||||||
add_headers_and_sources(clickhouse_common_io IO)
|
add_headers_and_sources(clickhouse_common_io IO)
|
||||||
|
add_headers_and_sources(clickhouse_common_io IO/S3)
|
||||||
list (REMOVE_ITEM clickhouse_common_io_sources Common/malloc.cpp Common/new_delete.cpp)
|
list (REMOVE_ITEM clickhouse_common_io_sources Common/malloc.cpp Common/new_delete.cpp)
|
||||||
|
|
||||||
if(USE_RDKAFKA)
|
if(USE_RDKAFKA)
|
||||||
|
@ -59,7 +59,7 @@ Otherwise you will get only exported symbols from program headers.
|
|||||||
# pragma clang diagnostic ignored "-Wunused-macros"
|
# pragma clang diagnostic ignored "-Wunused-macros"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __msan_unpoison_string(X)
|
#define __msan_unpoison_string(X) // NOLINT
|
||||||
#if defined(__has_feature)
|
#if defined(__has_feature)
|
||||||
# if __has_feature(memory_sanitizer)
|
# if __has_feature(memory_sanitizer)
|
||||||
# undef __msan_unpoison_string
|
# undef __msan_unpoison_string
|
||||||
|
@ -187,11 +187,6 @@ static inline size_t tabulation(UInt64 x)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t _intHash64(UInt64 x)
|
|
||||||
{
|
|
||||||
return static_cast<size_t>(intHash64(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const size_t BUF_SIZE = 1024;
|
const size_t BUF_SIZE = 1024;
|
||||||
|
|
||||||
@ -284,7 +279,7 @@ int main(int argc, char ** argv)
|
|||||||
|
|
||||||
if (!method || method == 1) test<identity> (n, data.data(), "0: identity");
|
if (!method || method == 1) test<identity> (n, data.data(), "0: identity");
|
||||||
if (!method || method == 2) test<intHash32> (n, data.data(), "1: intHash32");
|
if (!method || method == 2) test<intHash32> (n, data.data(), "1: intHash32");
|
||||||
if (!method || method == 3) test<_intHash64>(n, data.data(), "2: intHash64");
|
if (!method || method == 3) test<intHash64> (n, data.data(), "2: intHash64");
|
||||||
if (!method || method == 4) test<hash3> (n, data.data(), "3: two rounds");
|
if (!method || method == 4) test<hash3> (n, data.data(), "3: two rounds");
|
||||||
if (!method || method == 5) test<hash4> (n, data.data(), "4: two rounds and two variables");
|
if (!method || method == 5) test<hash4> (n, data.data(), "4: two rounds and two variables");
|
||||||
if (!method || method == 6) test<hash5> (n, data.data(), "5: two rounds with less ops");
|
if (!method || method == 6) test<hash5> (n, data.data(), "5: two rounds with less ops");
|
||||||
|
@ -40,74 +40,75 @@ DataTypePtr convertMySQLDataType(MultiEnum<MySQLDataTypesSupport> type_support,
|
|||||||
{
|
{
|
||||||
// we expect mysql_data_type to be either "basic_type" or "type_with_params(param1, param2, ...)"
|
// we expect mysql_data_type to be either "basic_type" or "type_with_params(param1, param2, ...)"
|
||||||
auto data_type = std::string_view(mysql_data_type);
|
auto data_type = std::string_view(mysql_data_type);
|
||||||
const auto param_start_pos = data_type.find("(");
|
const auto param_start_pos = data_type.find('(');
|
||||||
const auto type_name = data_type.substr(0, param_start_pos);
|
const auto type_name = data_type.substr(0, param_start_pos);
|
||||||
|
|
||||||
DataTypePtr res = [&]() -> DataTypePtr {
|
DataTypePtr res;
|
||||||
if (type_name == "tinyint")
|
|
||||||
{
|
|
||||||
if (is_unsigned)
|
|
||||||
return std::make_shared<DataTypeUInt8>();
|
|
||||||
else
|
|
||||||
return std::make_shared<DataTypeInt8>();
|
|
||||||
}
|
|
||||||
if (type_name == "smallint")
|
|
||||||
{
|
|
||||||
if (is_unsigned)
|
|
||||||
return std::make_shared<DataTypeUInt16>();
|
|
||||||
else
|
|
||||||
return std::make_shared<DataTypeInt16>();
|
|
||||||
}
|
|
||||||
if (type_name == "int" || type_name == "mediumint")
|
|
||||||
{
|
|
||||||
if (is_unsigned)
|
|
||||||
return std::make_shared<DataTypeUInt32>();
|
|
||||||
else
|
|
||||||
return std::make_shared<DataTypeInt32>();
|
|
||||||
}
|
|
||||||
if (type_name == "bigint")
|
|
||||||
{
|
|
||||||
if (is_unsigned)
|
|
||||||
return std::make_shared<DataTypeUInt64>();
|
|
||||||
else
|
|
||||||
return std::make_shared<DataTypeInt64>();
|
|
||||||
}
|
|
||||||
if (type_name == "float")
|
|
||||||
return std::make_shared<DataTypeFloat32>();
|
|
||||||
if (type_name == "double")
|
|
||||||
return std::make_shared<DataTypeFloat64>();
|
|
||||||
if (type_name == "date")
|
|
||||||
return std::make_shared<DataTypeDate>();
|
|
||||||
if (type_name == "binary")
|
|
||||||
return std::make_shared<DataTypeFixedString>(length);
|
|
||||||
if (type_name == "datetime" || type_name == "timestamp")
|
|
||||||
{
|
|
||||||
if (!type_support.isSet(MySQLDataTypesSupport::DATETIME64))
|
|
||||||
return std::make_shared<DataTypeDateTime>();
|
|
||||||
|
|
||||||
if (type_name == "timestamp" && scale == 0)
|
if (type_name == "tinyint")
|
||||||
{
|
{
|
||||||
return std::make_shared<DataTypeDateTime>();
|
if (is_unsigned)
|
||||||
}
|
res = std::make_shared<DataTypeUInt8>();
|
||||||
else if (type_name == "datetime" || type_name == "timestamp")
|
else
|
||||||
{
|
res = std::make_shared<DataTypeInt8>();
|
||||||
return std::make_shared<DataTypeDateTime64>(scale);
|
}
|
||||||
}
|
else if (type_name == "smallint")
|
||||||
}
|
{
|
||||||
|
if (is_unsigned)
|
||||||
if (type_support.isSet(MySQLDataTypesSupport::DECIMAL) && (type_name == "numeric" || type_name == "decimal"))
|
res = std::make_shared<DataTypeUInt16>();
|
||||||
|
else
|
||||||
|
res = std::make_shared<DataTypeInt16>();
|
||||||
|
}
|
||||||
|
else if (type_name == "int" || type_name == "mediumint")
|
||||||
|
{
|
||||||
|
if (is_unsigned)
|
||||||
|
res = std::make_shared<DataTypeUInt32>();
|
||||||
|
else
|
||||||
|
res = std::make_shared<DataTypeInt32>();
|
||||||
|
}
|
||||||
|
else if (type_name == "bigint")
|
||||||
|
{
|
||||||
|
if (is_unsigned)
|
||||||
|
res = std::make_shared<DataTypeUInt64>();
|
||||||
|
else
|
||||||
|
res = std::make_shared<DataTypeInt64>();
|
||||||
|
}
|
||||||
|
else if (type_name == "float")
|
||||||
|
res = std::make_shared<DataTypeFloat32>();
|
||||||
|
else if (type_name == "double")
|
||||||
|
res = std::make_shared<DataTypeFloat64>();
|
||||||
|
else if (type_name == "date")
|
||||||
|
res = std::make_shared<DataTypeDate>();
|
||||||
|
else if (type_name == "binary")
|
||||||
|
res = std::make_shared<DataTypeFixedString>(length);
|
||||||
|
else if (type_name == "datetime" || type_name == "timestamp")
|
||||||
|
{
|
||||||
|
if (!type_support.isSet(MySQLDataTypesSupport::DATETIME64))
|
||||||
{
|
{
|
||||||
if (precision <= DecimalUtils::maxPrecision<Decimal32>())
|
res = std::make_shared<DataTypeDateTime>();
|
||||||
return std::make_shared<DataTypeDecimal<Decimal32>>(precision, scale);
|
|
||||||
else if (precision <= DecimalUtils::maxPrecision<Decimal64>())
|
|
||||||
return std::make_shared<DataTypeDecimal<Decimal64>>(precision, scale);
|
|
||||||
else if (precision <= DecimalUtils::maxPrecision<Decimal128>())
|
|
||||||
return std::make_shared<DataTypeDecimal<Decimal128>>(precision, scale);
|
|
||||||
}
|
}
|
||||||
|
else if (type_name == "timestamp" && scale == 0)
|
||||||
|
{
|
||||||
|
res = std::make_shared<DataTypeDateTime>();
|
||||||
|
}
|
||||||
|
else if (type_name == "datetime" || type_name == "timestamp")
|
||||||
|
{
|
||||||
|
res = std::make_shared<DataTypeDateTime64>(scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type_support.isSet(MySQLDataTypesSupport::DECIMAL) && (type_name == "numeric" || type_name == "decimal"))
|
||||||
|
{
|
||||||
|
if (precision <= DecimalUtils::maxPrecision<Decimal32>())
|
||||||
|
res = std::make_shared<DataTypeDecimal<Decimal32>>(precision, scale);
|
||||||
|
else if (precision <= DecimalUtils::maxPrecision<Decimal64>())
|
||||||
|
res = std::make_shared<DataTypeDecimal<Decimal64>>(precision, scale);
|
||||||
|
else if (precision <= DecimalUtils::maxPrecision<Decimal128>())
|
||||||
|
res = std::make_shared<DataTypeDecimal<Decimal128>>(precision, scale);
|
||||||
|
}
|
||||||
|
|
||||||
/// Also String is fallback for all unknown types.
|
/// Also String is fallback for all unknown types.
|
||||||
return std::make_shared<DataTypeString>();
|
if (!res)
|
||||||
}();
|
res = std::make_shared<DataTypeString>();
|
||||||
|
|
||||||
if (is_nullable)
|
if (is_nullable)
|
||||||
res = std::make_shared<DataTypeNullable>(res);
|
res = std::make_shared<DataTypeNullable>(res);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <Interpreters/Context.h>
|
#include <Interpreters/Context.h>
|
||||||
#include "DiskS3.h"
|
#include "DiskS3.h"
|
||||||
#include "Disks/DiskCacheWrapper.h"
|
#include "Disks/DiskCacheWrapper.h"
|
||||||
#include "Disks/DiskCacheWrapper.cpp"
|
|
||||||
#include "Disks/DiskFactory.h"
|
#include "Disks/DiskFactory.h"
|
||||||
#include "ProxyConfiguration.h"
|
#include "ProxyConfiguration.h"
|
||||||
#include "ProxyListConfiguration.h"
|
#include "ProxyListConfiguration.h"
|
||||||
|
@ -92,7 +92,7 @@ private:
|
|||||||
src_offset = src_offsets[i];
|
src_offset = src_offsets[i];
|
||||||
dst_offset += src_length;
|
dst_offset += src_length;
|
||||||
|
|
||||||
if (src_length > 1 && dst_data[dst_offset - 2] != trailing_char_str.front())
|
if (src_length > 1 && dst_data[dst_offset - 2] != UInt8(trailing_char_str.front()))
|
||||||
{
|
{
|
||||||
dst_data[dst_offset - 1] = trailing_char_str.front();
|
dst_data[dst_offset - 1] = trailing_char_str.front();
|
||||||
dst_data[dst_offset] = 0;
|
dst_data[dst_offset] = 0;
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
|
#include <Common/config.h>
|
||||||
|
|
||||||
|
#if USE_AWS_S3
|
||||||
|
|
||||||
#include "PocoHTTPClient.h"
|
#include "PocoHTTPClient.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <IO/HTTPCommon.h>
|
#include <IO/HTTPCommon.h>
|
||||||
#include <IO/S3/PocoHTTPResponseStream.h>
|
#include <IO/S3/PocoHTTPResponseStream.h>
|
||||||
#include <IO/S3/PocoHTTPResponseStream.cpp>
|
|
||||||
#include <Common/Stopwatch.h>
|
#include <Common/Stopwatch.h>
|
||||||
#include <aws/core/http/HttpRequest.h>
|
#include <aws/core/http/HttpRequest.h>
|
||||||
#include <aws/core/http/HttpResponse.h>
|
#include <aws/core/http/HttpResponse.h>
|
||||||
@ -15,6 +18,7 @@
|
|||||||
#include <Poco/Net/HTTPResponse.h>
|
#include <Poco/Net/HTTPResponse.h>
|
||||||
#include <common/logger_useful.h>
|
#include <common/logger_useful.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ProfileEvents
|
namespace ProfileEvents
|
||||||
{
|
{
|
||||||
extern const Event S3ReadMicroseconds;
|
extern const Event S3ReadMicroseconds;
|
||||||
@ -65,7 +69,7 @@ std::shared_ptr<Aws::Http::HttpResponse> PocoHTTPClient::MakeRequest(
|
|||||||
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const
|
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const
|
||||||
{
|
{
|
||||||
auto response = Aws::MakeShared<Aws::Http::Standard::StandardHttpResponse>("PocoHTTPClient", request);
|
auto response = Aws::MakeShared<Aws::Http::Standard::StandardHttpResponse>("PocoHTTPClient", request);
|
||||||
MakeRequestInternal(request, response, readLimiter, writeLimiter);
|
makeRequestInternal(request, response, readLimiter, writeLimiter);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,11 +79,11 @@ std::shared_ptr<Aws::Http::HttpResponse> PocoHTTPClient::MakeRequest(
|
|||||||
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const
|
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const
|
||||||
{
|
{
|
||||||
auto response = Aws::MakeShared<Aws::Http::Standard::StandardHttpResponse>("PocoHTTPClient", request);
|
auto response = Aws::MakeShared<Aws::Http::Standard::StandardHttpResponse>("PocoHTTPClient", request);
|
||||||
MakeRequestInternal(*request, response, readLimiter, writeLimiter);
|
makeRequestInternal(*request, response, readLimiter, writeLimiter);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PocoHTTPClient::MakeRequestInternal(
|
void PocoHTTPClient::makeRequestInternal(
|
||||||
Aws::Http::HttpRequest & request,
|
Aws::Http::HttpRequest & request,
|
||||||
std::shared_ptr<Aws::Http::Standard::StandardHttpResponse> & response,
|
std::shared_ptr<Aws::Http::Standard::StandardHttpResponse> & response,
|
||||||
Aws::Utils::RateLimits::RateLimiterInterface *,
|
Aws::Utils::RateLimits::RateLimiterInterface *,
|
||||||
@ -101,7 +105,7 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
EnumSize,
|
EnumSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto selectMetric = [&request](S3MetricType type)
|
auto select_metric = [&request](S3MetricType type)
|
||||||
{
|
{
|
||||||
const ProfileEvents::Event events_map[][2] = {
|
const ProfileEvents::Event events_map[][2] = {
|
||||||
{ProfileEvents::S3ReadMicroseconds, ProfileEvents::S3WriteMicroseconds},
|
{ProfileEvents::S3ReadMicroseconds, ProfileEvents::S3WriteMicroseconds},
|
||||||
@ -128,12 +132,12 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
throw Exception("Unsupported request method", ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("Unsupported request method", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Count));
|
ProfileEvents::increment(select_metric(S3MetricType::Count));
|
||||||
|
|
||||||
const int MAX_REDIRECT_ATTEMPTS = 10;
|
static constexpr int max_redirect_attempts = 10;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (int attempt = 0; attempt < MAX_REDIRECT_ATTEMPTS; ++attempt)
|
for (int attempt = 0; attempt < max_redirect_attempts; ++attempt)
|
||||||
{
|
{
|
||||||
Poco::URI poco_uri(uri);
|
Poco::URI poco_uri(uri);
|
||||||
|
|
||||||
@ -202,7 +206,7 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
auto & response_body_stream = session->receiveResponse(poco_response);
|
auto & response_body_stream = session->receiveResponse(poco_response);
|
||||||
|
|
||||||
watch.stop();
|
watch.stop();
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Microseconds), watch.elapsedMicroseconds());
|
ProfileEvents::increment(select_metric(S3MetricType::Microseconds), watch.elapsedMicroseconds());
|
||||||
|
|
||||||
int status_code = static_cast<int>(poco_response.getStatus());
|
int status_code = static_cast<int>(poco_response.getStatus());
|
||||||
LOG_DEBUG(log, "Response status: {}, {}", status_code, poco_response.getReason());
|
LOG_DEBUG(log, "Response status: {}, {}", status_code, poco_response.getReason());
|
||||||
@ -214,7 +218,7 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
uri = location;
|
uri = location;
|
||||||
LOG_DEBUG(log, "Redirecting request to new location: {}", location);
|
LOG_DEBUG(log, "Redirecting request to new location: {}", location);
|
||||||
|
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Redirects));
|
ProfileEvents::increment(select_metric(S3MetricType::Redirects));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -240,11 +244,11 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
|
|
||||||
if (status_code == 429 || status_code == 503)
|
if (status_code == 429 || status_code == 503)
|
||||||
{ // API throttling
|
{ // API throttling
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Throttling));
|
ProfileEvents::increment(select_metric(S3MetricType::Throttling));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Errors));
|
ProfileEvents::increment(select_metric(S3MetricType::Errors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -261,7 +265,9 @@ void PocoHTTPClient::MakeRequestInternal(
|
|||||||
response->SetClientErrorType(Aws::Client::CoreErrors::NETWORK_CONNECTION);
|
response->SetClientErrorType(Aws::Client::CoreErrors::NETWORK_CONNECTION);
|
||||||
response->SetClientErrorMessage(getCurrentExceptionMessage(false));
|
response->SetClientErrorMessage(getCurrentExceptionMessage(false));
|
||||||
|
|
||||||
ProfileEvents::increment(selectMetric(S3MetricType::Errors));
|
ProfileEvents::increment(select_metric(S3MetricType::Errors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const override;
|
Aws::Utils::RateLimits::RateLimiterInterface * writeLimiter) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeRequestInternal(
|
void makeRequestInternal(
|
||||||
Aws::Http::HttpRequest & request,
|
Aws::Http::HttpRequest & request,
|
||||||
std::shared_ptr<Aws::Http::Standard::StandardHttpResponse> & response,
|
std::shared_ptr<Aws::Http::Standard::StandardHttpResponse> & response,
|
||||||
Aws::Utils::RateLimits::RateLimiterInterface * readLimiter,
|
Aws::Utils::RateLimits::RateLimiterInterface * readLimiter,
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#include <Common/config.h>
|
||||||
|
|
||||||
|
#if USE_AWS_S3
|
||||||
|
|
||||||
#include "PocoHTTPClientFactory.h"
|
#include "PocoHTTPClientFactory.h"
|
||||||
|
|
||||||
#include <IO/S3/PocoHTTPClient.h>
|
#include <IO/S3/PocoHTTPClient.h>
|
||||||
@ -32,3 +36,5 @@ std::shared_ptr<Aws::Http::HttpRequest> PocoHTTPClientFactory::CreateHttpRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
#include <Common/config.h>
|
||||||
|
|
||||||
|
#if USE_AWS_S3
|
||||||
|
|
||||||
|
|
||||||
#include "PocoHTTPResponseStream.h"
|
#include "PocoHTTPResponseStream.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -10,3 +15,5 @@ PocoHTTPResponseStream::PocoHTTPResponseStream(std::shared_ptr<Poco::Net::HTTPCl
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -12,9 +12,7 @@
|
|||||||
# include <aws/s3/S3Client.h>
|
# include <aws/s3/S3Client.h>
|
||||||
# include <aws/core/http/HttpClientFactory.h>
|
# include <aws/core/http/HttpClientFactory.h>
|
||||||
# include <IO/S3/PocoHTTPClientFactory.h>
|
# include <IO/S3/PocoHTTPClientFactory.h>
|
||||||
# include <IO/S3/PocoHTTPClientFactory.cpp>
|
|
||||||
# include <IO/S3/PocoHTTPClient.h>
|
# include <IO/S3/PocoHTTPClient.h>
|
||||||
# include <IO/S3/PocoHTTPClient.cpp>
|
|
||||||
# include <boost/algorithm/string.hpp>
|
# include <boost/algorithm/string.hpp>
|
||||||
# include <Poco/URI.h>
|
# include <Poco/URI.h>
|
||||||
# include <re2/re2.h>
|
# include <re2/re2.h>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <Columns/ColumnVector.h>
|
#include <Columns/ColumnVector.h>
|
||||||
|
|
||||||
// I know that inclusion of .cpp is not good at all
|
// I know that inclusion of .cpp is not good at all
|
||||||
#include <Storages/MergeTree/MergeTreeDataPartWriterOnDisk.cpp>
|
#include <Storages/MergeTree/MergeTreeDataPartWriterOnDisk.cpp> // NOLINT
|
||||||
|
|
||||||
using namespace DB;
|
using namespace DB;
|
||||||
static Block getBlockWithSize(size_t required_size_in_bytes, size_t size_of_row_in_bytes)
|
static Block getBlockWithSize(size_t required_size_in_bytes, size_t size_of_row_in_bytes)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <Columns/ColumnVector.h>
|
#include <Columns/ColumnVector.h>
|
||||||
|
|
||||||
// I know that inclusion of .cpp is not good at all
|
// I know that inclusion of .cpp is not good at all
|
||||||
#include <Storages/MergeTree/MergeTreeDataPartWriterCompact.cpp>
|
#include <Storages/MergeTree/MergeTreeDataPartWriterCompact.cpp> // NOLINT
|
||||||
|
|
||||||
using namespace DB;
|
using namespace DB;
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <Core/Field.h>
|
#include <Core/Field.h>
|
||||||
#include <Core/Types.h>
|
#include <Core/Types.h>
|
||||||
#include <Parsers/ASTFunction.h>
|
#include <Parsers/ASTFunction.h>
|
||||||
#include <Parsers/ASTIdentifier.cpp>
|
|
||||||
#include <Parsers/ASTIdentifier.h>
|
#include <Parsers/ASTIdentifier.h>
|
||||||
#include <Parsers/ASTLiteral.h>
|
#include <Parsers/ASTLiteral.h>
|
||||||
#include <Parsers/ASTSelectQuery.h>
|
#include <Parsers/ASTSelectQuery.h>
|
||||||
@ -16,6 +15,7 @@
|
|||||||
#include <Parsers/formatAST.h>
|
#include <Parsers/formatAST.h>
|
||||||
#include <Parsers/parseQuery.h>
|
#include <Parsers/parseQuery.h>
|
||||||
|
|
||||||
|
|
||||||
using ColumnType = uint32_t;
|
using ColumnType = uint32_t;
|
||||||
using TableAndColumn = std::pair<std::string, std::string>;
|
using TableAndColumn = std::pair<std::string, std::string>;
|
||||||
pcg64 rng;
|
pcg64 rng;
|
||||||
@ -92,7 +92,7 @@ TableAndColumn get_table_a_column(const std::string & c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum type : ColumnType
|
enum Type : ColumnType
|
||||||
{
|
{
|
||||||
i = 1,
|
i = 1,
|
||||||
// int
|
// int
|
||||||
@ -114,9 +114,11 @@ enum type : ColumnType
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::map<ColumnType, std::string> type_definition = {
|
std::map<ColumnType, std::string> type_definition =
|
||||||
{type::i, "Int64"}, {type::f, "Float64"}, {type::s, "String"}, {type::d, "Date"}, {type::dt, "DateTime"}, {type::b, "UInt8"}
|
{
|
||||||
|
{Type::i, "Int64"}, {Type::f, "Float64"}, {Type::s, "String"}, {Type::d, "Date"}, {Type::dt, "DateTime"}, {Type::b, "UInt8"}
|
||||||
};
|
};
|
||||||
|
|
||||||
ColumnType time_type(std::string value)
|
ColumnType time_type(std::string value)
|
||||||
{
|
{
|
||||||
if (value.length() == 12)
|
if (value.length() == 12)
|
||||||
@ -124,14 +126,14 @@ ColumnType time_type(std::string value)
|
|||||||
for (size_t i : {5, 8})
|
for (size_t i : {5, 8})
|
||||||
{
|
{
|
||||||
if (value[i] != '-')
|
if (value[i] != '-')
|
||||||
return type::s;
|
return Type::s;
|
||||||
}
|
}
|
||||||
for (size_t i : {1, 2, 3, 4, 6, 7, 9, 10})
|
for (size_t i : {1, 2, 3, 4, 6, 7, 9, 10})
|
||||||
{
|
{
|
||||||
if (!isdigit(value[i]))
|
if (!isdigit(value[i]))
|
||||||
return type::s;
|
return Type::s;
|
||||||
}
|
}
|
||||||
return type::d;
|
return Type::d;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.length() == 21)
|
if (value.length() == 21)
|
||||||
@ -139,18 +141,18 @@ ColumnType time_type(std::string value)
|
|||||||
for (size_t i : {5, 8})
|
for (size_t i : {5, 8})
|
||||||
{
|
{
|
||||||
if (value[i] != '-')
|
if (value[i] != '-')
|
||||||
return type::s;
|
return Type::s;
|
||||||
}
|
}
|
||||||
for (size_t i : {14, 17})
|
for (size_t i : {14, 17})
|
||||||
{
|
{
|
||||||
if (value[i] != '-')
|
if (value[i] != '-')
|
||||||
return type::s;
|
return Type::s;
|
||||||
}
|
}
|
||||||
if (value[11] != '-')
|
if (value[11] != '-')
|
||||||
return type::s;
|
return Type::s;
|
||||||
return type::dt;
|
return Type::dt;
|
||||||
}
|
}
|
||||||
return type::s;
|
return Type::s;
|
||||||
}
|
}
|
||||||
// Casting inner clickhouse parser type to our type
|
// Casting inner clickhouse parser type to our type
|
||||||
ColumnType type_cast(int t)
|
ColumnType type_cast(int t)
|
||||||
@ -164,21 +166,21 @@ ColumnType type_cast(int t)
|
|||||||
case 19:
|
case 19:
|
||||||
case 20:
|
case 20:
|
||||||
case 21:
|
case 21:
|
||||||
return type::i;
|
return Type::i;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
return type::f;
|
return Type::f;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
return type::s;
|
return Type::s;
|
||||||
|
|
||||||
case 17:
|
case 17:
|
||||||
return type::a | type::all;
|
return Type::a | Type::all;
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
return type::t | type::all;
|
return Type::t | Type::all;
|
||||||
}
|
}
|
||||||
return type::all;
|
return Type::all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -197,28 +199,28 @@ public:
|
|||||||
, is_array(is_a) {}
|
, is_array(is_a) {}
|
||||||
|
|
||||||
std::string value{};
|
std::string value{};
|
||||||
ColumnType type = type::all;
|
ColumnType type = Type::all;
|
||||||
bool is_array = false;
|
bool is_array = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, FuncRet> func_to_return_type = {
|
std::map<std::string, FuncRet> func_to_return_type = {
|
||||||
{"divide", FuncRet(type::f, "")}, {"e", FuncRet(type::f, "e()")}, {"pi", FuncRet(type::f, "pi()")}, {"exp", FuncRet(type::f, "")},
|
{"divide", FuncRet(Type::f, "")}, {"e", FuncRet(Type::f, "e()")}, {"pi", FuncRet(Type::f, "pi()")}, {"exp", FuncRet(Type::f, "")},
|
||||||
{"log", FuncRet(type::f,"")}, {"exp2", FuncRet(type::f, "")}, {"log2", FuncRet(type::f, "")}, {"exp10", FuncRet(type::f, "")},
|
{"log", FuncRet(Type::f,"")}, {"exp2", FuncRet(Type::f, "")}, {"log2", FuncRet(Type::f, "")}, {"exp10", FuncRet(Type::f, "")},
|
||||||
{"log10", FuncRet(type::f, "")}, {"sqrt", FuncRet(type::f, "")}, {"cbrt", FuncRet(type::f, "")}, {"erf", FuncRet(type::f, "")},
|
{"log10", FuncRet(Type::f, "")}, {"sqrt", FuncRet(Type::f, "")}, {"cbrt", FuncRet(Type::f, "")}, {"erf", FuncRet(Type::f, "")},
|
||||||
{"erfc", FuncRet(type::f, "")}, {"lgamma", FuncRet(type::f, "")}, {"tgamma", FuncRet(type::f, "")}, {"sin", FuncRet(type::f, "")},
|
{"erfc", FuncRet(Type::f, "")}, {"lgamma", FuncRet(Type::f, "")}, {"tgamma", FuncRet(Type::f, "")}, {"sin", FuncRet(Type::f, "")},
|
||||||
{"cos", FuncRet(type::f, "")}, {"tan", FuncRet(type::f, "")}, {"asin", FuncRet(type::f, "")}, {"acos", FuncRet(type::f, "")},
|
{"cos", FuncRet(Type::f, "")}, {"tan", FuncRet(Type::f, "")}, {"asin", FuncRet(Type::f, "")}, {"acos", FuncRet(Type::f, "")},
|
||||||
{"atan", FuncRet(type::f, "")}, {"pow", FuncRet(type::f, "")}, {"splitbystring", FuncRet(type::s | type::a,"")},
|
{"atan", FuncRet(Type::f, "")}, {"pow", FuncRet(Type::f, "")}, {"splitbystring", FuncRet(Type::s | Type::a,"")},
|
||||||
{"splitbychar", FuncRet(type::s | type::a, "")}, {"alphatokens", FuncRet(type::s | type::a, "")}, {"toyear", FuncRet(type::i, "")},
|
{"splitbychar", FuncRet(Type::s | Type::a, "")}, {"alphatokens", FuncRet(Type::s | Type::a, "")}, {"toyear", FuncRet(Type::i, "")},
|
||||||
{"tomonth", FuncRet(type::i, "")}, {"todayofmonth", FuncRet(type::i, "")}, {"tohour", FuncRet(type::dt, "")}, {"tominute", FuncRet(type::dt, "")},
|
{"tomonth", FuncRet(Type::i, "")}, {"todayofmonth", FuncRet(Type::i, "")}, {"tohour", FuncRet(Type::dt, "")}, {"tominute", FuncRet(Type::dt, "")},
|
||||||
{"toseconds", FuncRet(type::dt, "")}, {"tounixtimestamp", FuncRet(type::i, "")}, {"tostartofyear", FuncRet(type::dt | type::d, "")},
|
{"toseconds", FuncRet(Type::dt, "")}, {"tounixtimestamp", FuncRet(Type::i, "")}, {"tostartofyear", FuncRet(Type::dt | Type::d, "")},
|
||||||
{"tostartofquater",FuncRet(type::dt | type::d, "")}, {"tostartofmonth", FuncRet(type::dt | type::d, "")}, {"tomonday", FuncRet(type::dt | type::d, "")},
|
{"tostartofquater",FuncRet(Type::dt | Type::d, "")}, {"tostartofmonth", FuncRet(Type::dt | Type::d, "")}, {"tomonday", FuncRet(Type::dt | Type::d, "")},
|
||||||
{"tostartoffiveminutes", FuncRet(type::dt, "")}, {"tostartoftenminutes", FuncRet(type::dt, "")}, {"tostartoffifteenminutes", FuncRet(type::dt, "")},
|
{"tostartoffiveminutes", FuncRet(Type::dt, "")}, {"tostartoftenminutes", FuncRet(Type::dt, "")}, {"tostartoffifteenminutes", FuncRet(Type::dt, "")},
|
||||||
{"tostartofinterval", FuncRet(type::dt, "")}, {"totime", FuncRet(type::dt, "")}, {"torelativemonthnum", FuncRet(type::i, "")},
|
{"tostartofinterval", FuncRet(Type::dt, "")}, {"totime", FuncRet(Type::dt, "")}, {"torelativemonthnum", FuncRet(Type::i, "")},
|
||||||
{"torelativeweeknum", FuncRet(type::i, "")}, {"torelativedaynum", FuncRet(type::i, "")}, {"torelativehournum", FuncRet(type::i, "")},
|
{"torelativeweeknum", FuncRet(Type::i, "")}, {"torelativedaynum", FuncRet(Type::i, "")}, {"torelativehournum", FuncRet(Type::i, "")},
|
||||||
{"torelativeminutenum", FuncRet(type::i, "")}, {"torelativesecondsnum", FuncRet(type::i, "")}, {"datediff", FuncRet(type::d | type::dt, "")},
|
{"torelativeminutenum", FuncRet(Type::i, "")}, {"torelativesecondsnum", FuncRet(Type::i, "")}, {"datediff", FuncRet(Type::d | Type::dt, "")},
|
||||||
{"formatdatetime", FuncRet(type::s, "")}, {"now", FuncRet(type::dt | type::d, "now()")}, {"today", FuncRet(type::d | type::dt, "today()")},
|
{"formatdatetime", FuncRet(Type::s, "")}, {"now", FuncRet(Type::dt | Type::d, "now()")}, {"today", FuncRet(Type::d | Type::dt, "today()")},
|
||||||
{"yesterday", FuncRet(type::d | type::dt, "yesterday()")}
|
{"yesterday", FuncRet(Type::d | Type::dt, "yesterday()")}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::set<std::string> func_args_same_types = {
|
std::set<std::string> func_args_same_types = {
|
||||||
@ -226,23 +228,23 @@ std::set<std::string> func_args_same_types = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, ColumnType> func_to_param_type = {
|
std::map<std::string, ColumnType> func_to_param_type = {
|
||||||
{"tostartofminute", type::dt}, {"plus", type::i | type::f | type::d | type::dt}, {"multiply", type::i | type::f},
|
{"tostartofminute", Type::dt}, {"plus", Type::i | Type::f | Type::d | Type::dt}, {"multiply", Type::i | Type::f},
|
||||||
{"minus", type::i | type::f | type::d | type::dt}, {"negate", type::i | type::f}, {"divide", type::i | type::f},
|
{"minus", Type::i | Type::f | Type::d | Type::dt}, {"negate", Type::i | Type::f}, {"divide", Type::i | Type::f},
|
||||||
{"abs", type::i | type::f}, {"gcd", type::i | type::f}, {"lcm", type::i | type::f}, {"bitnot", type::i}, {"bitshiftleft", type::i},
|
{"abs", Type::i | Type::f}, {"gcd", Type::i | Type::f}, {"lcm", Type::i | Type::f}, {"bitnot", Type::i}, {"bitshiftleft", Type::i},
|
||||||
{"bitshiftright", type::i}, {"bittest", type::i}, {"exp", type::i | type::f}, {"log", type::i | type::f},
|
{"bitshiftright", Type::i}, {"bittest", Type::i}, {"exp", Type::i | Type::f}, {"log", Type::i | Type::f},
|
||||||
{"exp2", type::i | type::f}, {"log2", type::i | type::f}, {"exp10", type::i | type::f}, {"log10", type::i | type::f},
|
{"exp2", Type::i | Type::f}, {"log2", Type::i | Type::f}, {"exp10", Type::i | Type::f}, {"log10", Type::i | Type::f},
|
||||||
{"sqrt", type::i | type::f}, {"cbrt", type::i | type::f}, {"erf", type::i | type::f}, {"erfc", type::i | type::f},
|
{"sqrt", Type::i | Type::f}, {"cbrt", Type::i | Type::f}, {"erf", Type::i | Type::f}, {"erfc", Type::i | Type::f},
|
||||||
{"lgamma", type::i | type::f}, {"tgamma", type::i | type::f}, {"sin", type::i | type::f}, {"cos", type::i | type::f},
|
{"lgamma", Type::i | Type::f}, {"tgamma", Type::i | Type::f}, {"sin", Type::i | Type::f}, {"cos", Type::i | Type::f},
|
||||||
{"tan", type::i | type::f}, {"asin", type::i | type::f}, {"acos", type::i | type::f}, {"atan", type::i | type::f},
|
{"tan", Type::i | Type::f}, {"asin", Type::i | Type::f}, {"acos", Type::i | Type::f}, {"atan", Type::i | Type::f},
|
||||||
{"pow", type::i | type::f}, {"arrayjoin", type::all | type::a}, {"substring", type::s}, {"splitbystring", type::s}, {"splitbychar", type::s},
|
{"pow", Type::i | Type::f}, {"arrayjoin", Type::all | Type::a}, {"substring", Type::s}, {"splitbystring", Type::s}, {"splitbychar", Type::s},
|
||||||
{"alphatokens", type::s}, {"toyear", type::d | type::dt}, {"tomonth", type::d | type::dt}, {"todayofmonth", type::d | type::dt}, {"tohour", type::dt},
|
{"alphatokens", Type::s}, {"toyear", Type::d | Type::dt}, {"tomonth", Type::d | Type::dt}, {"todayofmonth", Type::d | Type::dt}, {"tohour", Type::dt},
|
||||||
{"tominute", type::dt}, {"tosecond", type::dt}, {"touixtimestamp", type::dt}, {"tostartofyear", type::d | type::dt},
|
{"tominute", Type::dt}, {"tosecond", Type::dt}, {"touixtimestamp", Type::dt}, {"tostartofyear", Type::d | Type::dt},
|
||||||
{"tostartofquarter", type::d | type::dt}, {"tostartofmonth", type::d | type::dt}, {"tomonday", type::d | type::dt},
|
{"tostartofquarter", Type::d | Type::dt}, {"tostartofmonth", Type::d | Type::dt}, {"tomonday", Type::d | Type::dt},
|
||||||
{"tostartoffiveminute", type::dt}, {"tostartoftenminutes", type::dt}, {"tostartoffifteenminutes", type::d | type::dt},
|
{"tostartoffiveminute", Type::dt}, {"tostartoftenminutes", Type::dt}, {"tostartoffifteenminutes", Type::d | Type::dt},
|
||||||
{"tostartofinterval", type::d | type::dt}, {"totime", type::d | type::dt}, {"torelativehonthnum", type::d | type::dt},
|
{"tostartofinterval", Type::d | Type::dt}, {"totime", Type::d | Type::dt}, {"torelativehonthnum", Type::d | Type::dt},
|
||||||
{"torelativeweeknum", type::d | type::dt}, {"torelativedaynum", type::d | type::dt}, {"torelativehournum", type::d | type::dt},
|
{"torelativeweeknum", Type::d | Type::dt}, {"torelativedaynum", Type::d | Type::dt}, {"torelativehournum", Type::d | Type::dt},
|
||||||
{"torelativeminutenum", type::d | type::dt}, {"torelativesecondnum", type::d | type::dt}, {"datediff", type::d | type::dt},
|
{"torelativeminutenum", Type::d | Type::dt}, {"torelativesecondnum", Type::d | Type::dt}, {"datediff", Type::d | Type::dt},
|
||||||
{"formatdatetime", type::dt}
|
{"formatdatetime", Type::dt}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -252,7 +254,7 @@ public:
|
|||||||
TableAndColumn name;
|
TableAndColumn name;
|
||||||
std::set<TableAndColumn> equals;
|
std::set<TableAndColumn> equals;
|
||||||
std::set<std::string> values;
|
std::set<std::string> values;
|
||||||
ColumnType type = type::all;
|
ColumnType type = Type::all;
|
||||||
bool is_array = false;
|
bool is_array = false;
|
||||||
|
|
||||||
Column() = default;
|
Column() = default;
|
||||||
@ -260,7 +262,7 @@ public:
|
|||||||
explicit Column(const std::string & column_name)
|
explicit Column(const std::string & column_name)
|
||||||
{
|
{
|
||||||
name = std::make_pair("", column_name);
|
name = std::make_pair("", column_name);
|
||||||
type = type::all;
|
type = Type::all;
|
||||||
}
|
}
|
||||||
|
|
||||||
void merge(Column other)
|
void merge(Column other)
|
||||||
@ -275,15 +277,15 @@ public:
|
|||||||
|
|
||||||
void printType() const
|
void printType() const
|
||||||
{
|
{
|
||||||
if (type & type::i)
|
if (type & Type::i)
|
||||||
std::cout << "I";
|
std::cout << "I";
|
||||||
if (type & type::f)
|
if (type & Type::f)
|
||||||
std::cout << "F";
|
std::cout << "F";
|
||||||
if (type & type::s)
|
if (type & Type::s)
|
||||||
std::cout << "S";
|
std::cout << "S";
|
||||||
if (type & type::d)
|
if (type & Type::d)
|
||||||
std::cout << "D";
|
std::cout << "D";
|
||||||
if (type & type::dt)
|
if (type & Type::dt)
|
||||||
std::cout << "DT";
|
std::cout << "DT";
|
||||||
if (is_array)
|
if (is_array)
|
||||||
std::cout << "ARR";
|
std::cout << "ARR";
|
||||||
@ -307,22 +309,22 @@ public:
|
|||||||
|
|
||||||
std::string generateOneValue() const
|
std::string generateOneValue() const
|
||||||
{
|
{
|
||||||
if (type & type::i)
|
if (type & Type::i)
|
||||||
return randomInteger();
|
return randomInteger();
|
||||||
|
|
||||||
if (type & type::f)
|
if (type & Type::f)
|
||||||
return randomFloat();
|
return randomFloat();
|
||||||
|
|
||||||
if (type & type::d)
|
if (type & Type::d)
|
||||||
return randomDate();
|
return randomDate();
|
||||||
|
|
||||||
if (type & type::dt)
|
if (type & Type::dt)
|
||||||
return randomDatetime();
|
return randomDatetime();
|
||||||
|
|
||||||
if (type & type::s)
|
if (type & Type::s)
|
||||||
return "'" + randomString(rng() % 40) + "'";
|
return "'" + randomString(rng() % 40) + "'";
|
||||||
|
|
||||||
if (type & type::b)
|
if (type & Type::b)
|
||||||
return "0";
|
return "0";
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -332,7 +334,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (values.size() > 2 && amount == 0)
|
if (values.size() > 2 && amount == 0)
|
||||||
return false;
|
return false;
|
||||||
while (values.size() < 1 or amount > 0)
|
while (values.empty() or amount > 0)
|
||||||
{
|
{
|
||||||
amount -= 1;
|
amount -= 1;
|
||||||
if (is_array)
|
if (is_array)
|
||||||
@ -357,18 +359,18 @@ public:
|
|||||||
|
|
||||||
void unifyType()
|
void unifyType()
|
||||||
{
|
{
|
||||||
if (type & type::i)
|
if (type & Type::i)
|
||||||
type = type::i;
|
type = Type::i;
|
||||||
else if (type & type::f)
|
else if (type & Type::f)
|
||||||
type = type::f;
|
type = Type::f;
|
||||||
else if (type & type::d)
|
else if (type & Type::d)
|
||||||
type = type::d;
|
type = Type::d;
|
||||||
else if (type & type::dt)
|
else if (type & Type::dt)
|
||||||
type = type::dt;
|
type = Type::dt;
|
||||||
else if (type & type::s)
|
else if (type & Type::s)
|
||||||
type = type::s;
|
type = Type::s;
|
||||||
else if (type & type::b)
|
else if (type & Type::b)
|
||||||
type = type::b;
|
type = Type::b;
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Error in determination column type " + name.first + '.' + name.second);
|
throw std::runtime_error("Error in determination column type " + name.first + '.' + name.second);
|
||||||
}
|
}
|
||||||
@ -381,13 +383,15 @@ decartMul(
|
|||||||
std::set<std::string> & mul)
|
std::set<std::string> & mul)
|
||||||
{
|
{
|
||||||
std::set<std::vector<std::string>> result;
|
std::set<std::vector<std::string>> result;
|
||||||
for (auto v : prev)
|
for (const auto & v : prev)
|
||||||
for (auto m : mul)
|
{
|
||||||
|
for (const auto & m : mul)
|
||||||
{
|
{
|
||||||
std::vector<std::string> tmp = v;
|
std::vector<std::string> tmp = v;
|
||||||
tmp.push_back(m);
|
tmp.push_back(m);
|
||||||
result.insert(tmp);
|
result.insert(tmp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +442,7 @@ public:
|
|||||||
{
|
{
|
||||||
name = other.name;
|
name = other.name;
|
||||||
columns.insert(other.columns.begin(), other.columns.end());
|
columns.insert(other.columns.begin(), other.columns.end());
|
||||||
for (auto desc : other.column_description)
|
for (const auto & desc : other.column_description)
|
||||||
column_description[desc.first].merge(desc.second);
|
column_description[desc.first].merge(desc.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +580,7 @@ public:
|
|||||||
|
|
||||||
void merge(TableList other)
|
void merge(TableList other)
|
||||||
{
|
{
|
||||||
for (auto table : other.tables)
|
for (const auto & table : other.tables)
|
||||||
tables[table.first].merge(table.second);
|
tables[table.first].merge(table.second);
|
||||||
nested.insert(other.nested.begin(), other.nested.end());
|
nested.insert(other.nested.begin(), other.nested.end());
|
||||||
if (main_table.empty())
|
if (main_table.empty())
|
||||||
@ -617,14 +621,14 @@ FuncRet arrayJoinFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
for (const auto & indent : indents)
|
for (const auto & indent : indents)
|
||||||
{
|
{
|
||||||
auto c = Column(indent);
|
auto c = Column(indent);
|
||||||
c.type = type::all;
|
c.type = Type::all;
|
||||||
c.is_array = true;
|
c.is_array = true;
|
||||||
if (columns.count(indent))
|
if (columns.count(indent))
|
||||||
columns[indent].merge(c);
|
columns[indent].merge(c);
|
||||||
else
|
else
|
||||||
columns[indent] = c;
|
columns[indent] = c;
|
||||||
}
|
}
|
||||||
FuncRet r(type::all, "");
|
FuncRet r(Type::all, "");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return FuncRet();
|
return FuncRet();
|
||||||
@ -637,7 +641,7 @@ FuncRet inFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
{
|
{
|
||||||
std::set<std::string> indents{};
|
std::set<std::string> indents{};
|
||||||
std::set<std::string> values{};
|
std::set<std::string> values{};
|
||||||
ColumnType type_value = type::all;
|
ColumnType type_value = Type::all;
|
||||||
|
|
||||||
for (auto & arg : x->arguments->children)
|
for (auto & arg : x->arguments->children)
|
||||||
{
|
{
|
||||||
@ -656,20 +660,20 @@ FuncRet inFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
for (auto & val : arr_values)
|
for (auto & val : arr_values)
|
||||||
{
|
{
|
||||||
type = type_cast(val.getType());
|
type = type_cast(val.getType());
|
||||||
if (type == type::s || type == type::d || type == type::dt)
|
if (type == Type::s || type == Type::d || type == Type::dt)
|
||||||
type = time_type(applyVisitor(DB::FieldVisitorToString(), val));
|
type = time_type(applyVisitor(DB::FieldVisitorToString(), val));
|
||||||
type_value &= type;
|
type_value &= type;
|
||||||
values.insert(applyVisitor(DB::FieldVisitorToString(), val));
|
values.insert(applyVisitor(DB::FieldVisitorToString(), val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (type & type::a)
|
if (type & Type::a)
|
||||||
{
|
{
|
||||||
auto arr_values = literal->value.get<DB::Array>();
|
auto arr_values = literal->value.get<DB::Array>();
|
||||||
routine(arr_values);
|
routine(arr_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type & type::a)
|
if (type & Type::a)
|
||||||
{
|
{
|
||||||
auto arr_values = literal->value.get<DB::Tuple>();
|
auto arr_values = literal->value.get<DB::Tuple>();
|
||||||
routine(arr_values);
|
routine(arr_values);
|
||||||
@ -685,7 +689,7 @@ FuncRet inFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
else
|
else
|
||||||
f = handlers[""];
|
f = handlers[""];
|
||||||
FuncRet ret = f(arg, columns);
|
FuncRet ret = f(arg, columns);
|
||||||
if (ret.value != "")
|
if (!ret.value.empty())
|
||||||
{
|
{
|
||||||
values.insert(ret.value);
|
values.insert(ret.value);
|
||||||
}
|
}
|
||||||
@ -703,7 +707,7 @@ FuncRet inFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
else
|
else
|
||||||
columns[indent] = c;
|
columns[indent] = c;
|
||||||
}
|
}
|
||||||
FuncRet r(type::b | type::i, "");
|
FuncRet r(Type::b | Type::i, "");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return FuncRet();
|
return FuncRet();
|
||||||
@ -716,7 +720,7 @@ FuncRet arrayFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
{
|
{
|
||||||
std::set<std::string> indents = {};
|
std::set<std::string> indents = {};
|
||||||
std::string value = "[";
|
std::string value = "[";
|
||||||
ColumnType type_value = type::i | type::f | type::d | type::dt | type::s;
|
ColumnType type_value = Type::i | Type::f | Type::d | Type::dt | Type::s;
|
||||||
bool no_indent = true;
|
bool no_indent = true;
|
||||||
for (const auto & arg : x->arguments->children)
|
for (const auto & arg : x->arguments->children)
|
||||||
{
|
{
|
||||||
@ -730,7 +734,7 @@ FuncRet arrayFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
if (literal)
|
if (literal)
|
||||||
{
|
{
|
||||||
ColumnType type = type_cast(literal->value.getType());
|
ColumnType type = type_cast(literal->value.getType());
|
||||||
if (type == type::s || type == type::d || type == type::dt)
|
if (type == Type::s || type == Type::d || type == Type::dt)
|
||||||
type = time_type(value);
|
type = time_type(value);
|
||||||
type_value &= type;
|
type_value &= type;
|
||||||
|
|
||||||
@ -764,7 +768,7 @@ FuncRet arithmeticFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
{
|
{
|
||||||
std::set<std::string> indents = {};
|
std::set<std::string> indents = {};
|
||||||
std::set<std::string> values = {};
|
std::set<std::string> values = {};
|
||||||
ColumnType type_value = type::i | type::f | type::d | type::dt;
|
ColumnType type_value = Type::i | Type::f | Type::d | Type::dt;
|
||||||
ColumnType args_types = 0;
|
ColumnType args_types = 0;
|
||||||
bool no_indent = true;
|
bool no_indent = true;
|
||||||
for (auto & arg : x->arguments->children)
|
for (auto & arg : x->arguments->children)
|
||||||
@ -793,11 +797,11 @@ FuncRet arithmeticFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
}
|
}
|
||||||
args_types |= type;
|
args_types |= type;
|
||||||
}
|
}
|
||||||
if (args_types & (type::d | type::dt))
|
if (args_types & (Type::d | Type::dt))
|
||||||
type_value -= type::f;
|
type_value -= Type::f;
|
||||||
if (args_types & type::f)
|
if (args_types & Type::f)
|
||||||
type_value -= type::d | type::dt;
|
type_value -= Type::d | Type::dt;
|
||||||
for (auto indent : indents)
|
for (const auto & indent : indents)
|
||||||
{
|
{
|
||||||
auto c = Column(indent);
|
auto c = Column(indent);
|
||||||
c.type = type_value;
|
c.type = type_value;
|
||||||
@ -807,14 +811,14 @@ FuncRet arithmeticFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
columns[indent] = c;
|
columns[indent] = c;
|
||||||
}
|
}
|
||||||
ColumnType ret_type = 0;
|
ColumnType ret_type = 0;
|
||||||
if (args_types & type::dt)
|
if (args_types & Type::dt)
|
||||||
ret_type = type::dt;
|
ret_type = Type::dt;
|
||||||
else if (args_types & type::d)
|
else if (args_types & Type::d)
|
||||||
ret_type = type::d | type::dt;
|
ret_type = Type::d | Type::dt;
|
||||||
else if (args_types & type::f)
|
else if (args_types & Type::f)
|
||||||
ret_type = type::f;
|
ret_type = Type::f;
|
||||||
else
|
else
|
||||||
ret_type = type::d | type::f | type::dt | type::i;
|
ret_type = Type::d | Type::f | Type::dt | Type::i;
|
||||||
FuncRet r(ret_type, "");
|
FuncRet r(ret_type, "");
|
||||||
if (no_indent)
|
if (no_indent)
|
||||||
{
|
{
|
||||||
@ -833,7 +837,7 @@ FuncRet likeFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
{
|
{
|
||||||
std::set<std::string> indents = {};
|
std::set<std::string> indents = {};
|
||||||
std::set<std::string> values = {};
|
std::set<std::string> values = {};
|
||||||
ColumnType type_value = type::s;
|
ColumnType type_value = Type::s;
|
||||||
for (auto & arg : x->arguments->children)
|
for (auto & arg : x->arguments->children)
|
||||||
{
|
{
|
||||||
auto ident = std::dynamic_pointer_cast<DB::ASTIdentifier>(arg);
|
auto ident = std::dynamic_pointer_cast<DB::ASTIdentifier>(arg);
|
||||||
@ -866,7 +870,7 @@ FuncRet likeFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
else
|
else
|
||||||
columns[indent] = c;
|
columns[indent] = c;
|
||||||
}
|
}
|
||||||
FuncRet r(type::b, "");
|
FuncRet r(Type::b, "");
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return FuncRet();
|
return FuncRet();
|
||||||
@ -874,22 +878,22 @@ FuncRet likeFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
|
|
||||||
FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
||||||
{
|
{
|
||||||
auto X = std::dynamic_pointer_cast<DB::ASTFunction>(ch);
|
auto x = std::dynamic_pointer_cast<DB::ASTFunction>(ch);
|
||||||
if (X)
|
if (x)
|
||||||
{
|
{
|
||||||
std::set<std::string> indents = {};
|
std::set<std::string> indents = {};
|
||||||
std::set<std::string> values = {};
|
std::set<std::string> values = {};
|
||||||
ColumnType type_value = type::all;
|
ColumnType type_value = Type::all;
|
||||||
bool is_array = false;
|
bool is_array = false;
|
||||||
bool no_indent = true;
|
bool no_indent = true;
|
||||||
if (func_to_param_type.count(boost::algorithm::to_lower_copy(X->name)))
|
if (func_to_param_type.count(boost::algorithm::to_lower_copy(x->name)))
|
||||||
{
|
{
|
||||||
type_value &= func_to_param_type[boost::algorithm::to_lower_copy(X->name)];
|
type_value &= func_to_param_type[boost::algorithm::to_lower_copy(x->name)];
|
||||||
is_array = func_to_param_type[boost::algorithm::to_lower_copy(X->name)] & type::a;
|
is_array = func_to_param_type[boost::algorithm::to_lower_copy(x->name)] & Type::a;
|
||||||
}
|
}
|
||||||
for (auto arg : X->arguments->children)
|
for (const auto & arg : x->arguments->children)
|
||||||
{
|
{
|
||||||
ColumnType type = type::all;
|
ColumnType type = Type::all;
|
||||||
std::string value;
|
std::string value;
|
||||||
auto ident = std::dynamic_pointer_cast<DB::ASTIdentifier>(arg);
|
auto ident = std::dynamic_pointer_cast<DB::ASTIdentifier>(arg);
|
||||||
if (ident)
|
if (ident)
|
||||||
@ -902,7 +906,7 @@ FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
{
|
{
|
||||||
value = applyVisitor(DB::FieldVisitorToString(), literal->value);
|
value = applyVisitor(DB::FieldVisitorToString(), literal->value);
|
||||||
type = type_cast(literal->value.getType());
|
type = type_cast(literal->value.getType());
|
||||||
is_array |= type & type::a;
|
is_array |= type & Type::a;
|
||||||
}
|
}
|
||||||
auto subfunc = std::dynamic_pointer_cast<DB::ASTFunction>(arg);
|
auto subfunc = std::dynamic_pointer_cast<DB::ASTFunction>(arg);
|
||||||
if (subfunc)
|
if (subfunc)
|
||||||
@ -922,31 +926,31 @@ FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
}
|
}
|
||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
{
|
{
|
||||||
if (type == type::i)
|
if (type == Type::i)
|
||||||
{
|
{
|
||||||
values.insert(value);
|
values.insert(value);
|
||||||
values.insert(value + " + " + randomInteger(1, 10));
|
values.insert(value + " + " + randomInteger(1, 10));
|
||||||
values.insert(value + " - " + randomInteger(1, 10));
|
values.insert(value + " - " + randomInteger(1, 10));
|
||||||
}
|
}
|
||||||
if (type == type::f)
|
if (type == Type::f)
|
||||||
{
|
{
|
||||||
values.insert(value);
|
values.insert(value);
|
||||||
values.insert(value + " + " + randomFloat(1, 10));
|
values.insert(value + " + " + randomFloat(1, 10));
|
||||||
values.insert(value + " - " + randomFloat(1, 10));
|
values.insert(value + " - " + randomFloat(1, 10));
|
||||||
}
|
}
|
||||||
if (type & type::s || type & type::d || type & type::dt)
|
if (type & Type::s || type & Type::d || type & Type::dt)
|
||||||
{
|
{
|
||||||
if (type == type::s)
|
if (type == Type::s)
|
||||||
type = time_type(value);
|
type = time_type(value);
|
||||||
if (type == type::s)
|
if (type == Type::s)
|
||||||
values.insert(value);
|
values.insert(value);
|
||||||
if (type & type::d)
|
if (type & Type::d)
|
||||||
{
|
{
|
||||||
values.insert(value);
|
values.insert(value);
|
||||||
values.insert("toDate(" + value + ") + " + randomInteger(1, 10));
|
values.insert("toDate(" + value + ") + " + randomInteger(1, 10));
|
||||||
values.insert("toDate(" + value + ") - " + randomInteger(1, 10));
|
values.insert("toDate(" + value + ") - " + randomInteger(1, 10));
|
||||||
}
|
}
|
||||||
else if (type & type::dt)
|
else if (type & Type::dt)
|
||||||
{
|
{
|
||||||
values.insert(value);
|
values.insert(value);
|
||||||
values.insert(
|
values.insert(
|
||||||
@ -956,7 +960,7 @@ FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (func_args_same_types.count(boost::algorithm::to_lower_copy(X->name)))
|
if (func_args_same_types.count(boost::algorithm::to_lower_copy(x->name)))
|
||||||
type_value &= type;
|
type_value &= type;
|
||||||
}
|
}
|
||||||
for (const auto & indent : indents)
|
for (const auto & indent : indents)
|
||||||
@ -965,7 +969,7 @@ FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
c.type = type_value;
|
c.type = type_value;
|
||||||
c.is_array = is_array;
|
c.is_array = is_array;
|
||||||
if (func_args_same_types.count(
|
if (func_args_same_types.count(
|
||||||
boost::algorithm::to_lower_copy(X->name)))
|
boost::algorithm::to_lower_copy(x->name)))
|
||||||
c.values = values;
|
c.values = values;
|
||||||
for (const auto & ind : indents)
|
for (const auto & ind : indents)
|
||||||
if (ind != indent)
|
if (ind != indent)
|
||||||
@ -976,31 +980,31 @@ FuncRet simpleFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
|
|||||||
else
|
else
|
||||||
columns[indent] = c;
|
columns[indent] = c;
|
||||||
}
|
}
|
||||||
if (func_to_return_type.count(boost::algorithm::to_lower_copy(X->name)))
|
if (func_to_return_type.count(boost::algorithm::to_lower_copy(x->name)))
|
||||||
{
|
{
|
||||||
if (no_indent)
|
if (no_indent)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
formatAST(*ch, ss);
|
formatAST(*ch, ss);
|
||||||
auto r = func_to_return_type[boost::algorithm::to_lower_copy(X->name)];
|
auto r = func_to_return_type[boost::algorithm::to_lower_copy(x->name)];
|
||||||
r.value = ss.str();
|
r.value = ss.str();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return func_to_return_type[boost::algorithm::to_lower_copy(X->name)];
|
return func_to_return_type[boost::algorithm::to_lower_copy(x->name)];
|
||||||
}
|
}
|
||||||
else if (func_to_param_type.count(
|
else if (func_to_param_type.count(
|
||||||
boost::algorithm::to_lower_copy(X->name)))
|
boost::algorithm::to_lower_copy(x->name)))
|
||||||
{
|
{
|
||||||
if (no_indent)
|
if (no_indent)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
formatAST(*ch, ss);
|
formatAST(*ch, ss);
|
||||||
return FuncRet(
|
return FuncRet(
|
||||||
func_to_param_type[boost::algorithm::to_lower_copy(X->name)],
|
func_to_param_type[boost::algorithm::to_lower_copy(x->name)],
|
||||||
ss.str());
|
ss.str());
|
||||||
}
|
}
|
||||||
return FuncRet(
|
return FuncRet(
|
||||||
func_to_param_type[boost::algorithm::to_lower_copy(X->name)],
|
func_to_param_type[boost::algorithm::to_lower_copy(x->name)],
|
||||||
"");
|
"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1070,7 +1074,7 @@ connectedEqualityFind(
|
|||||||
std::set<TableAndColumn> & visited)
|
std::set<TableAndColumn> & visited)
|
||||||
{
|
{
|
||||||
std::set<TableAndColumn> result;
|
std::set<TableAndColumn> result;
|
||||||
for (auto & column : now.equals)
|
for (const auto & column : now.equals)
|
||||||
if (!visited.count(column))
|
if (!visited.count(column))
|
||||||
{
|
{
|
||||||
visited.insert(column);
|
visited.insert(column);
|
||||||
@ -1117,18 +1121,18 @@ unificateColumns(
|
|||||||
result[column.second.name.first + "." + column.second.name.second],
|
result[column.second.name.first + "." + column.second.name.second],
|
||||||
result,
|
result,
|
||||||
visited);
|
visited);
|
||||||
for (auto c : equal)
|
for (const auto & c : equal)
|
||||||
result[c.first + "." + c.second].equals = equal;
|
result[c.first + "." + c.second].equals = equal;
|
||||||
}
|
}
|
||||||
for (auto & column : result)
|
for (auto & column : result)
|
||||||
for (auto e : column.second.equals)
|
for (const auto & e : column.second.equals)
|
||||||
column.second.merge(result[e.first + "." + e.second]);
|
column.second.merge(result[e.first + "." + e.second]);
|
||||||
|
|
||||||
for (auto & column : result)
|
for (auto & column : result)
|
||||||
{
|
{
|
||||||
column.second.unifyType();
|
column.second.unifyType();
|
||||||
if (column.second.generateValues())
|
if (column.second.generateValues())
|
||||||
for (auto e : column.second.equals)
|
for (const auto & e : column.second.equals)
|
||||||
result[e.first + "." + e.second].merge(column.second);
|
result[e.first + "." + e.second].merge(column.second);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1174,18 +1178,18 @@ void parseSelectQuery(DB::ASTPtr ast, TableList & all_tables)
|
|||||||
for (auto & child : x->children)
|
for (auto & child : x->children)
|
||||||
{
|
{
|
||||||
auto ch = std::dynamic_pointer_cast<DB::ASTTablesInSelectQueryElement>(child);
|
auto ch = std::dynamic_pointer_cast<DB::ASTTablesInSelectQueryElement>(child);
|
||||||
auto TEast = std::dynamic_pointer_cast<DB::ASTTableExpression>(ch->table_expression);
|
auto table_expression_ast = std::dynamic_pointer_cast<DB::ASTTableExpression>(ch->table_expression);
|
||||||
if (TEast && TEast->database_and_table_name)
|
if (table_expression_ast && table_expression_ast->database_and_table_name)
|
||||||
{
|
{
|
||||||
auto table_name = *(getIndent(TEast->database_and_table_name).begin());
|
auto table_name = *(getIndent(table_expression_ast->database_and_table_name).begin());
|
||||||
all_tables.addTable(table_name);
|
all_tables.addTable(table_name);
|
||||||
auto alias = getAlias(ch);
|
auto alias = getAlias(ch);
|
||||||
if (!alias.empty())
|
if (!alias.empty())
|
||||||
all_tables.aliases[alias] = table_name;
|
all_tables.aliases[alias] = table_name;
|
||||||
}
|
}
|
||||||
if (TEast && TEast->subquery)
|
if (table_expression_ast && table_expression_ast->subquery)
|
||||||
{
|
{
|
||||||
for (auto select : getSelect(TEast->subquery))
|
for (const auto & select : getSelect(table_expression_ast->subquery))
|
||||||
{
|
{
|
||||||
TableList local;
|
TableList local;
|
||||||
parseSelectQuery(select, local);
|
parseSelectQuery(select, local);
|
||||||
|
Loading…
Reference in New Issue
Block a user