mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
fixup
This commit is contained in:
parent
500b9bac03
commit
bc34e0ff94
@ -8,3 +8,4 @@ services:
|
||||
MONGO_INITDB_ROOT_PASSWORD: clickhouse
|
||||
ports:
|
||||
- 27018:27017
|
||||
command: --profile=2 --verbose
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "DictionaryStructure.h"
|
||||
#include "getDictionaryConfigurationFromAST.h"
|
||||
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
@ -41,6 +43,9 @@ DictionaryPtr DictionaryFactory::create(
|
||||
const DictionaryStructure dict_struct{config, config_prefix + ".structure"};
|
||||
|
||||
DictionarySourcePtr source_ptr = DictionarySourceFactory::instance().create(name, config, config_prefix + ".source", dict_struct, context, check_source_config);
|
||||
LOG_TRACE(&Poco::Logger::get("DictionaryFactory"),
|
||||
"Created dictionary source '" << source_ptr->toString()
|
||||
<< "' for dictionary '" << name << "'");
|
||||
|
||||
const auto & layout_type = keys.front();
|
||||
|
||||
|
@ -35,11 +35,13 @@ void registerDictionarySourceMongoDB(DictionarySourceFactory & factory)
|
||||
}
|
||||
|
||||
|
||||
#include <common/logger_useful.h>
|
||||
#include <Poco/MongoDB/Array.h>
|
||||
#include <Poco/MongoDB/Connection.h>
|
||||
#include <Poco/MongoDB/Cursor.h>
|
||||
#include <Poco/MongoDB/Database.h>
|
||||
#include <Poco/MongoDB/ObjectId.h>
|
||||
#include <Poco/URI.h>
|
||||
#include <Poco/Util/AbstractConfiguration.h>
|
||||
#include <Poco/Version.h>
|
||||
|
||||
@ -187,15 +189,38 @@ MongoDBDictionarySource::MongoDBDictionarySource(
|
||||
, db{db_}
|
||||
, collection{collection_}
|
||||
, sample_block{sample_block_}
|
||||
, connection{std::make_shared<Poco::MongoDB::Connection>(host, port)}
|
||||
, connection{std::make_shared<Poco::MongoDB::Connection>()}
|
||||
{
|
||||
if (!uri.empty())
|
||||
{
|
||||
Poco::URI poco_uri(uri);
|
||||
|
||||
// Parse database from URI. This is required for correctness -- the
|
||||
// cursor is created using database name and colleciton name, so we have
|
||||
// to specify them properly.
|
||||
db = poco_uri.getPath();
|
||||
// getPath() may return a leading slash, remove it.
|
||||
if (!db.empty() && db[0] == '/')
|
||||
{
|
||||
db.erase(0, 1);
|
||||
}
|
||||
|
||||
// Parse some other parts from URI, for logging and display purposes.
|
||||
host = poco_uri.getHost();
|
||||
port = poco_uri.getPort();
|
||||
user = poco_uri.getUserInfo();
|
||||
if (size_t separator = user.find(':'); separator != std::string::npos)
|
||||
{
|
||||
user.resize(separator);
|
||||
}
|
||||
|
||||
// Connect with URI.
|
||||
Poco::MongoDB::Connection::SocketFactory socket_factory;
|
||||
connection->connect(uri, socket_factory);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Connect with host/port/user/etc.
|
||||
connection->connect(host, port);
|
||||
if (!user.empty())
|
||||
{
|
||||
|
@ -72,12 +72,12 @@ public:
|
||||
private:
|
||||
const DictionaryStructure dict_struct;
|
||||
const std::string uri;
|
||||
const std::string host;
|
||||
const UInt16 port;
|
||||
const std::string user;
|
||||
std::string host;
|
||||
UInt16 port;
|
||||
std::string user;
|
||||
const std::string password;
|
||||
const std::string method;
|
||||
const std::string db;
|
||||
std::string db;
|
||||
const std::string collection;
|
||||
Block sample_block;
|
||||
|
||||
|
@ -179,6 +179,11 @@ class SourceMongo(ExternalSource):
|
||||
result = tbl.insert_many(to_insert)
|
||||
|
||||
class SourceMongoURI(SourceMongo):
|
||||
def compatible_with_layout(self, layout):
|
||||
# It is enough to test one layout for this dictionary, since we're
|
||||
# only testing that the connection with URI works.
|
||||
return layout.name == 'flat'
|
||||
|
||||
def get_source_str(self, table_name):
|
||||
return '''
|
||||
<mongodb>
|
||||
|
@ -106,9 +106,9 @@ VALUES = {
|
||||
|
||||
|
||||
LAYOUTS = [
|
||||
Layout("flat"),
|
||||
Layout("hashed"),
|
||||
Layout("cache"),
|
||||
Layout("flat"),
|
||||
Layout("complex_key_hashed"),
|
||||
Layout("complex_key_cache"),
|
||||
Layout("range_hashed"),
|
||||
@ -117,7 +117,7 @@ LAYOUTS = [
|
||||
|
||||
SOURCES = [
|
||||
SourceMongo("MongoDB", "localhost", "27018", "mongo1", "27017", "root", "clickhouse"),
|
||||
SourceMongoURI("MongoDB", "localhost", "27018", "mongo1", "27017", "root", "clickhouse"),
|
||||
SourceMongoURI("MongoDB_URI", "localhost", "27018", "mongo1", "27017", "root", "clickhouse"),
|
||||
SourceMySQL("MySQL", "localhost", "3308", "mysql1", "3306", "root", "clickhouse"),
|
||||
SourceClickHouse("RemoteClickHouse", "localhost", "9000", "clickhouse1", "9000", "default", ""),
|
||||
SourceClickHouse("LocalClickHouse", "localhost", "9000", "node", "9000", "default", ""),
|
||||
|
Loading…
Reference in New Issue
Block a user