Revert "Merge 'enable_catalog_dev' into 'cnch-dev'"

This reverts commit e181b2a622.
This commit is contained in:
fredwang 2024-12-03 09:27:47 +08:00
parent 815b00a7ab
commit 78dd9d28a5
5 changed files with 19 additions and 17 deletions

View File

@ -1494,10 +1494,15 @@ int Server::main(const std::vector<std::string> & /*args*/)
throw; throw;
} }
// WARNING: There is a undesired restriction on FDB. Each process could only init one fdb client otherwise it will panic. // Note:: just for test.
// so if we use fdb as the kv storage, the config for external and internal catalog must be the same. {
ExternalCatalog::Mgr::init(*global_context, global_context->getConfigRef()); // WARNING: There is a undesired restriction on FDB. Each process could only init one fdb client otherwise it will panic.
// so if we use fdb as the kv storage, the config for external and internal catalog must be the same.
if (global_context->getCnchConfigRef().has(ExternalCatalog::Mgr::configPrefix()))
{
ExternalCatalog::Mgr::init(*global_context, global_context->getCnchConfigRef());
}
}
/// Check sanity of MergeTreeSettings on server startup /// Check sanity of MergeTreeSettings on server startup
global_context->getMergeTreeSettings().sanityCheck(settings); global_context->getMergeTreeSettings().sanityCheck(settings);
global_context->getReplicatedMergeTreeSettings().sanityCheck(settings); global_context->getReplicatedMergeTreeSettings().sanityCheck(settings);

View File

@ -21,12 +21,12 @@ extern const int UNKNOWN_CATALOG;
namespace DB::ExternalCatalog namespace DB::ExternalCatalog
{ {
CnchExternalCatalogMgr::CnchExternalCatalogMgr(Context & _context, const Poco::Util::AbstractConfiguration & mgr_conf, const String & config_prefix) CnchExternalCatalogMgr::CnchExternalCatalogMgr(Context & _context, const Poco::Util::AbstractConfiguration & mgr_conf)
: context(_context), metastore_conf(mgr_conf, config_prefix) : context(_context), metastore_conf(mgr_conf, Mgr::configPrefix())
{ {
// TODO(ExterncalCatalog):: check whether to set FLAGS_consul_agent_addr here. // TODO(ExterncalCatalog):: check whether to set FLAGS_consul_agent_addr here.
meta_proxy = std::make_shared<Catalog::MetastoreProxy>(metastore_conf, mgr_conf.getBool("enable_cnch_write_remote_catalog", true)); meta_proxy = std::make_shared<Catalog::MetastoreProxy>(metastore_conf, mgr_conf.getBool("enable_cnch_write_remote_catalog", true));
name_space = mgr_conf.getString("catalog.name_space", "default"); name_space = mgr_conf.getString(Mgr::configPrefix() + ".name_space", "default");
} }
bool CnchExternalCatalogMgr::createCatalog(const std::string & catalog_name, PlainConfigs * catalog_meta, const TxnTimestamp & ts) bool CnchExternalCatalogMgr::createCatalog(const std::string & catalog_name, PlainConfigs * catalog_meta, const TxnTimestamp & ts)
{ {

View File

@ -16,7 +16,7 @@ namespace DB::ExternalCatalog
class CnchExternalCatalogMgr : public IExternalCatalogMgr class CnchExternalCatalogMgr : public IExternalCatalogMgr
{ {
public: public:
CnchExternalCatalogMgr(Context & context, const Poco::Util::AbstractConfiguration & conf, const String & config_prefix); CnchExternalCatalogMgr(Context & context, const Poco::Util::AbstractConfiguration & conf);
~CnchExternalCatalogMgr() override = default; ~CnchExternalCatalogMgr() override = default;
bool createCatalog(const std::string & catalog_name, PlainConfigs * catalog_meta, const TxnTimestamp & ts) override; bool createCatalog(const std::string & catalog_name, PlainConfigs * catalog_meta, const TxnTimestamp & ts) override;

View File

@ -1,8 +1,5 @@
#include <memory> #include <memory>
#include "Common/Config/MetastoreConfig.h"
#include <Common/Exception.h>
#include <common/logger_useful.h>
#include <ExternalCatalog/CnchExternalCatalogMgr.h> #include <ExternalCatalog/CnchExternalCatalogMgr.h>
#include <ExternalCatalog/IExternalCatalogMgr.h> #include <ExternalCatalog/IExternalCatalogMgr.h>
#include <ExternalCatalog/InMemoryExternalCatalogMgr.h> #include <ExternalCatalog/InMemoryExternalCatalogMgr.h>
@ -22,8 +19,7 @@ namespace Mgr
void init(Context & _context, [[maybe_unused]] const Poco::Util::AbstractConfiguration & conf) void init(Context & _context, [[maybe_unused]] const Poco::Util::AbstractConfiguration & conf)
{ {
//TODO(renming):: add more implementation //TODO(renming):: add more implementation
auto prefix = conf.has(configPrefix()) ? configPrefix() : CATALOG_SERVICE_CONFIGURE; auto key_mgr_type = configPrefix() + ".type";
auto key_mgr_type = prefix + ".type";
auto log = getLogger("ExternalCatalogMgr"); auto log = getLogger("ExternalCatalogMgr");
if (!conf.has(key_mgr_type)) if (!conf.has(key_mgr_type))
{ {
@ -39,7 +35,7 @@ namespace Mgr
{ {
// this will created an catalog mgr backed by fdb/bytekv and etc. // this will created an catalog mgr backed by fdb/bytekv and etc.
LOG_DEBUG(log, "Use kv-backed external catalog manager"); LOG_DEBUG(log, "Use kv-backed external catalog manager");
mgr_ptr = std::make_unique<CnchExternalCatalogMgr>(_context, conf, prefix); mgr_ptr = std::make_unique<CnchExternalCatalogMgr>(_context, conf);
} }
assert(mgr_ptr != nullptr); assert(mgr_ptr != nullptr);

View File

@ -51,9 +51,10 @@ Block InterpreterShowCreateQuery::getSampleBlock()
BlockInputStreamPtr InterpreterShowCreateQuery::executeForExternalImpl() BlockInputStreamPtr InterpreterShowCreateQuery::executeForExternalImpl()
{ {
auto catalog_name = query_ptr->as<ASTShowCreateExternalCatalogQuery>()->catalog; auto catalog_name = query_ptr->as<ASTShowCreateExternalCatalogQuery>()->catalog;
auto create_query =ExternalCatalog::Mgr::instance().getCatalogCreateQuery(catalog_name); auto create_query = ExternalCatalog::Mgr::instance().getCatalogCreateQuery(catalog_name);
if(!create_query.has_value() || create_query->empty()){ if (create_query->empty())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "catalog {} does not exist",catalog_name); {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "catalog {} does not exist", catalog_name);
} }
MutableColumnPtr column = ColumnString::create(); MutableColumnPtr column = ColumnString::create();
column->insert(create_query.value()); column->insert(create_query.value());